Solved "mount -t zfs -fw" can't mount a ZFS volume 100% of the time.....

Hello.

Actually I have installed my daily work FreeBSD 13.1-RELEASE system on the ZFS disk ada0 :

Code:
=>       40  976773088  ada0  GPT  (466G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    4194304     3  freebsd-swap  (2.0G)
    4728832  972044288     4  freebsd-zfs  (464G)
  976773120          8        - free -  (4.0K)

instead,on the disk ada2 I have installed most of the services and applications that I have installed on the drive ada0 and sometimes I switch to this system (it's the same 13.1-RELEASE,but on a UFS2 fs) :

Code:
=>       40  625142368  ada2  GPT  (298G)
         40     532480     1  efi  (260M)
     532520  616030208     2  freebsd-ufs  (294G)
  616562728    8388608     3  freebsd-swap  (4.0G)
  624951336     191072        - free -  (93M)

sometimes,when I'm on the system installed on the disk ada2,I want to mount the root partition of the system installed on /dev/ada0p4 (FreeBSD-ZFS on the disk ada0) and to do that,I use these commands :

Code:
zfs mount -a
mount -t zfs -fw zroot/ROOT/31-03-2022-b /mnt/freebsd-zfs

what's the problem ? the problem is that it works a lot of time,but not everytime and I don't understand the reason. Sometimes,like now,it gives the error below. Is there a more secure way to mount the ZFS partition so that it works 100% ? thanks.

Code:
# mount: zroot/ROOT/31-03-2022-b: No such file or directory
 
Last edited by a moderator:
UPDATE : I tried this,it almost worked,but unfortunately I don't see every file and folder stored on the disk :

Code:
# zpool import -f -R /mnt/freebsd-zfs zroot
 ls /mnt/freebsd-zfs
tmp    usr    var    zroot

this also didn't work :

Code:
# zpool import -f -R /mnt/freebsd-zfs zroot/ROOT/31-03-2022-b
cannot import 'zroot/ROOT/31-03-2022-b': no such pool available

I want mount the path "zroot/ROOT/31-03-2022-b" :

Code:
# sudo zfs list

NAME                      USED  AVAIL     REFER  MOUNTPOINT
zroot                     216G   230G       96K  /mnt/freebsd-zfs/zroot
zroot/ROOT                203G   230G       96K  none
zroot/ROOT/31-03-2022-a   512K   230G     43.4G  /mnt/freebsd-zfs
zroot/ROOT/31-03-2022-b   203G   230G      175G  /mnt/freebsd-zfs
zroot/tmp                10.6M   230G     10.6M  /mnt/freebsd-zfs/tmp
zroot/usr                11.7G   230G       96K  /mnt/freebsd-zfs/usr
zroot/usr/home            192K   230G      192K  /mnt/freebsd-zfs/usr/home
zroot/usr/ports          8.33G   230G     8.33G  /mnt/freebsd-zfs/usr/ports
zroot/usr/src            3.36G   230G     3.36G  /mnt/freebsd-zfs/usr/src
zroot/var                1.26G   230G       96K  /mnt/freebsd-zfs/var
zroot/var/audit            96K   230G       96K  /mnt/freebsd-zfs/var/audit
zroot/var/crash          1.11G   230G     1.11G  /mnt/freebsd-zfs/var/crash
zroot/var/log            3.59M   230G     3.59M  /mnt/freebsd-zfs/var/log
zroot/var/mail            130M   230G      130M  /mnt/freebsd-zfs/var/mail
zroot/var/tmp            18.1M   230G     18.1M  /mnt/freebsd-zfs/var/tmp
 
Last edited by a moderator:
this seems to work :

Code:
zpool import -f -R /mnt/freebsd-zfs zrootzfs
set canmount=on zroot/ROOT/31-03-2022-b
sudo zfs list

NAME                      USED  AVAIL     REFER  MOUNTPOINT
zroot                     216G   230G       96K  /mnt/freebsd-zfs/
zrootzroot/ROOT                203G   230G       96K  none
zroot/ROOT/31-03-2022-a   512K   230G     43.4G  /mnt/freebsd-zfs
zroot/ROOT/31-03-2022-b   203G   230G      175G  /mnt/freebsd-zfs
zroot/tmp                10.6M   230G     10.6M  /mnt/freebsd-zfs/tmp
zroot/usr                11.7G   230G       96K  /mnt/freebsd-zfs/usr
zroot/usr/home            192K   230G      192K  /mnt/freebsd-zfs/usr/home
zroot/usr/ports          8.33G   230G     8.33G  /mnt/freebsd-zfs/usr/ports
zroot/usr/src            3.36G   230G     3.36G  /mnt/freebsd-zfs/usr/src
zroot/var                1.26G   230G       96K  /mnt/freebsd-zfs/var
zroot/var/audit            96K   230G       96K  /mnt/freebsd-zfs/var/audit
zroot/var/crash          1.11G   230G     1.11G  /mnt/freebsd-zfs/var/crash
zroot/var/log            3.59M   230G     3.59M  /mnt/freebsd-zfs/var/log
zroot/var/mail            130M   230G      130M  /mnt/freebsd-zfs/var/mail
zroot/var/tmp            18.1M   230G     18.1M  /mnt/freebsd-zfs/var/tmp

zfs get mounted,canmount,mountpoint zroot/ROOT/31-03-2022-b

NAME                     PROPERTY    VALUE             SOURCE
zroot/ROOT/31-03-2022-b  mounted     yes               -
zroot/ROOT/31-03-2022-b  canmount    on                local
zroot/ROOT/31-03-2022-b  mountpoint  /mnt/freebsd-zfs  local
 
Last edited by a moderator:
Do first a "zfs umount /mnt/freebsd-zfs" ?
And check there are no files in /mnt/freebsd-zfs before you do a mount of /mnt/freebsd-zfs?
 
Code:
zfs mount -a
mount -t zfs -fw zroot/ROOT/31-03-2022-b /mnt/freebsd-zfs
what's the problem ?
ZFS pools are not mounted, they are imported, but you have figured that already out.

If the ZFS installation on disk ada0 was installed automatically (not manually), then the installer has set the root dataset ( zroot/ROOT/default ) to canmount=noauto. That means it is not mounted automatically when imported. It must be mounted manually.

Code:
# zfs list -o name,canmount,mountpoint zroot/ROOT/default
NAME                     CANMOUNT   MOUNTPOINT
zroot/ROOT/default       noauto    /

zfsprops(7)
Code:
     canmount=on|off|noauto
       ...
       When set to noauto, a dataset can only be mounted and unmounted
       explicitly.  The dataset is not mounted automatically when the dataset
       is created or imported, nor is it mounted by the zfs mount -a command
       or unmounted by the zfs unmount -a command.

The proper commands to import pool "zroot" and mount root are:
Code:
# zpool import -fR /mnt/freebsd-zfs zroot
# zfs mount zroot/ROOT/31-03-2022-b

# sudo zfs list
There is no need for super-user privileges to execute zfs-list(8), zfs list will do.
 
ZFS pools are not mounted, they are imported, but you have figured that already out.

If the ZFS installation on disk ada0 was installed automatically (not manually), then the installer has set the root dataset ( zroot/ROOT/default ) to canmount=noauto. That means it is not mounted automatically when imported. It must be mounted manually.

Code:
# zfs list -o name,canmount,mountpoint zroot/ROOT/default
NAME                     CANMOUNT   MOUNTPOINT
zroot/ROOT/default       noauto    /

zfsprops(7)
Code:
     canmount=on|off|noauto
       ...
       When set to noauto, a dataset can only be mounted and unmounted
       explicitly.  The dataset is not mounted automatically when the dataset
       is created or imported, nor is it mounted by the zfs mount -a command
       or unmounted by the zfs unmount -a command.

The proper commands to import pool "zroot" and mount root are:
Code:
# zpool import -fR /mnt/freebsd-zfs zroot
# zfs mount zroot/ROOT/31-03-2022-b


There is no need for super-user privileges to execute zfs-list(8), zfs list will do.

yeah,I didn't think to be able to figure it out.
 
Back
Top