Solved Root on ZFS how to mount /?

Firstly sorry for the bad thread title. I'm not sure how to summarize my issue.

I have to alter a legacy automated build process which uses a FreeBSD 11.0 virtual machine.

When I run the virtual machine image in Virtualbox I can log in and see the following zpool, zfs, mount details:

Code:
root@vm:~ # zpool list
NAME                 SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
tank  31.8G  9.01G  22.7G         -    17%    28%  1.00x  ONLINE  -

root@vm:~ # zfs list
NAME                            USED  AVAIL  REFER  MOUNTPOINT
tank             11.0G  19.7G   150M  legacy
tank/swap        2.06G  21.7G  33.5M  -
tank/tmp           25K  19.7G    25K  /tmp
tank/usr         8.82G  19.7G  8.82G  /usr
tank/usr/home      19K  19.7G    19K  /usr/home
tank/var         15.6M  19.7G  1.69M  /var
tank/var/crash     19K  19.7G    19K  /var/crash
tank/var/db      13.7M  19.7G  4.47M  /var/db
tank/var/db/pkg  9.25M  19.7G  9.25M  /var/db/pkg
tank/var/empty     19K  19.7G    19K  /var/empty
tank/var/log     69.5K  19.7G  69.5K  /var/log
tank/var/mail      24K  19.7G    24K  /var/mail
tank/var/run     36.5K  19.7G  36.5K  /var/run
tank/var/tmp       19K  19.7G    19K  /var/tmp

root@vm:~ # mount
tank on / (zfs, local, nfsv4acls)
devfs on /dev (devfs, local, multilabel)
tank/tmp on /tmp (zfs, local, nosuid, nfsv4acls)
tank/usr on /usr (zfs, local, nfsv4acls)
tank/usr/home on /usr/home (zfs, local, nfsv4acls)
tank/var on /var (zfs, local, nfsv4acls)
tank/var/crash on /var/crash (zfs, local, noexec, nosuid, nfsv4acls)
tank/var/db on /var/db (zfs, local, noexec, nosuid, nfsv4acls)
tank/var/db/pkg on /var/db/pkg (zfs, local, nosuid, nfsv4acls)
tank/var/empty on /var/empty (zfs, local, noexec, nosuid, read-only, nfsv4acls)
tank/var/log on /var/log (zfs, local, noexec, nosuid, nfsv4acls)
tank/var/mail on /var/mail (zfs, local, noexec, nosuid, nfsv4acls)
tank/var/run on /var/run (zfs, local, noexec, nosuid, nfsv4acls)
tank/var/tmp on /var/tmp (zfs, local, nosuid, nfsv4acls)

root@vm:~ # df
Filesystem                                          1K-blocks     Used     Avail Capacity  Mounted on
tank                                   20824019   153677  20670342     1%    /
devfs                                                       1        1         0   100%    /dev
tank/tmp                               20670367       25  20670342     0%    /tmp
tank/usr                               29916283  9245941  20670342    31%    /usr
tank/usr/home                          20670361       19  20670342     0%    /usr/home
tank/var                               20672069     1726  20670342     0%    /var
tank/var/crash                         20670361       19  20670342     0%    /var/crash
tank/var/db                            20674922     4579  20670342     0%    /var/db
tank/var/db/pkg                        20679819     9477  20670342     0%    /var/db/pkg
tank/var/empty                         20670361       19  20670342     0%    /var/empty
tank/var/log                           20670412       69  20670342     0%    /var/log
tank/var/mail                          20670366       24  20670342     0%    /var/mail
tank/var/run                           20670379       36  20670342     0%    /var/run
tank/var/tmp                           20670361       19  20670342     0%    /var/tmp

I have been able to mount the vm disk image, from linux, using the following commands.

Code:
qemu-nbd --connect=/dev/nbd0 buildvm.qcow2

zpool import -f -R /root/mnt -d /dev/nbd0p2 tank

I can see the following disk, zfs file systems and mounts.

Code:
fdisk /dev/nbd0

Welcome to fdisk (util-linux 2.35.2).                                                                                                                                                                                                 
Changes will remain in memory only, until you decide to write them.                                                                                                                                                                   
Be careful before using the write command.

The device contains 'zfs_member' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Command (m for help): p

Disk /dev/nbd0: 32 GiB, 34359738368 bytes, 67108864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 735B77FE-EC63-11EB-AF25-080027020974

Device      Start      End  Sectors  Size Type
/dev/nbd0p1    40      551      512  256K FreeBSD boot
/dev/nbd0p2   552 67108823 67108272   32G FreeBSD ZFS

zpool list
NAME                 SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
tank  31.8G  9.01G  22.7G        -         -    17%    28%  1.00x    ONLINE  /root/mnt

 zfs list
NAME                            USED  AVAIL     REFER  MOUNTPOINT
tank             11.0G  19.7G      150M  legacy
tank/swap        2.06G  21.7G     33.5M  -
tank/tmp           24K  19.7G       24K  /root/mnt/tmp
tank/usr         8.82G  19.7G     8.82G  /root/mnt/usr
tank/usr/home      19K  19.7G       19K  /root/mnt/usr/home
tank/var         15.6M  19.7G     1.69M  /root/mnt/var
tank/var/crash     19K  19.7G       19K  /root/mnt/var/crash
tank/var/db      13.7M  19.7G     4.47M  /root/mnt/var/db
tank/var/db/pkg  9.25M  19.7G     9.25M  /root/mnt/var/db/pkg
tank/var/empty     19K  19.7G       19K  /root/mnt/var/empty
tank/var/log     69.5K  19.7G     69.5K  /root/mnt/var/log
tank/var/mail      24K  19.7G       24K  /root/mnt/var/mail
tank/var/run     36.5K  19.7G     36.5K  /root/mnt/var/run
tank/var/tmp       19K  19.7G       19K  /root/mnt/var/tmp

zfs mount
tank/tmp          /root/mnt/tmp
tank/var          /root/mnt/var
tank/usr          /root/mnt/usr
tank/var/log      /root/mnt/var/log
tank/var/crash    /root/mnt/var/crash
tank/var/empty    /root/mnt/var/empty
tank/var/tmp      /root/mnt/var/tmp
tank/var/db       /root/mnt/var/db
tank/var/mail     /root/mnt/var/mail
tank/var/run      /root/mnt/var/run
tank/usr/home     /root/mnt/usr/home
tank/var/db/pkg   /root/mnt/var/db/pkg

s -lha /root/mnt/
total 13K
drwxr-xr-x 5 root root 4.0K Aug 2 15:48 .
drwx------ 6 root root 4.0K Aug 3 14:40 ..
drwxrwxrwt 7 root root 7 Aug 3 04:19 tmp
drwxr-xr-x 16 root root 16 Jul 24 10:42 usr
drwxr-xr-x 24 root root 24 Aug 2 17:36 var

The problem is that I need to access files in /root/mnt/etc but the / partition is not mounted.

How can I do that?
 
I have to alter a legacy automated build process which uses a FreeBSD 11.0 virtual machine.
A good time to update it. FreeBSD 11.0 has been end-of-life since November 2017.

The problem is that I need to access files in /root/mnt/etc but the / partition is not mounted.
zfs mount <dataset> (Oh, right, that doesn't work due to the 'legacy')
mount tank /tmp/somewhere/nice (which works on FreeBSD, no idea if Linux is able to do that).
 
Back
Top