ZFS ZFS dataset /usr empty

Hi,

just out of curiosity: we migrated a server after problems. On the old server, I have datasets like these:

Code:
[root@rescue ~]# zfs list
NAME                 USED  AVAIL     REFER  MOUNTPOINT
zroot               14.5T   760G      128K  none
zroot/ROOT           205G   760G      128K  none
zroot/ROOT/default   205G   760G      205G  /
zroot/files         14.2T   760G     14.2T  /files
zroot/tmp           12.7G   760G     12.7G  /tmp
zroot/usr           13.1G   760G      151K  /usr
zroot/usr/home      10.7G   760G     10.7G  /usr/home
zroot/usr/ports     2.36G   760G     2.36G  /usr/ports
zroot/usr/src        128K   760G      128K  /usr/src
zroot/var           34.2G   760G      128K  /var
zroot/var/audit     10.1G   760G     10.1G  /var/audit
zroot/var/crash     21.0G   760G     21.0G  /var/crash
zroot/var/log       1.57G   760G     1.57G  /var/log
zroot/var/mail      1.53G   760G     1.53G  /var/mail
zroot/var/tmp       15.3M   760G     15.3M  /var/tmp
[root@rescue ~]#

The /usr dataset is actually empty when mounting it - so, can I do anything to recover the 13.1 GB?

Thanks,
Thomas Mack
 
It's supposed to be empty and not mounted. It's just there so zroot/usr/home, zroot/usr/src, etc. are all logical. The same is true for zroot/var (also not mounted and just there so the underlying datasets are ordered correctly).

Code:
root@maelcum:~ # zfs list -o name,canmount,mountpoint
NAME                CANMOUNT  MOUNTPOINT
zroot               on        /zroot
zroot/ROOT          on        none
zroot/ROOT/default  noauto    /
zroot/tmp           on        /tmp
zroot/usr           off       /usr
zroot/usr/home      on        /usr/home
zroot/usr/ports     on        /usr/ports
zroot/usr/src       on        /usr/src
zroot/var           off       /var
zroot/var/audit     on        /var/audit
zroot/var/crash     on        /var/crash
zroot/var/log       on        /var/log
zroot/var/mail      on        /var/mail
zroot/var/tmp       on        /var/tmp
 
When I mount it on the rescue system under /mnt ( zfs mount -o mountpoint=/mnt zroot/ROOT/default), it mounts itself under / unfortunately?

I see the directory then, but the rescue system is in an inconsistent state then.
 
When I mount it on the rescue system under /mnt (zfs mount -o mountpoint=/mnt zroot/ROOT/default), it mounts itself under / unfortunately?
Import the pool with the -R option. zpool import -R /mnt mypool

Code:
             -R root
                     Sets the cachefile property to none and the altroot
                     property to root.
 
Ok, thanks, that did the trick.

Takes some time to not only get used to the ZFS basics but to understand enough, to work with it in problematic cases as well.
 
OS root pools are special in the way they're organized. When you want to import them and mount them, it's best to not leave things to the normal automation.

First use zpool import -N -R /mnt zroot, which imports the pool but mounts nothing, then zfs mount zroot/ROOT/default for the / file system (it has the property canmount=noauto—you might have multiple root file systems if you use boot environments), then you can do zfs mount -a to do the rest.
 
So, there is still some funny behaviour in this constellation.

When I mount everything including zroot/usr, /usr/* files beyond datasets in zroot/usr/* are hidden. When I umount zroot/usr, everything gets visible. That's a different behaviour than with zroot/var and zroot/var/*.

So, something seems to be wrong with this installation (which doesn't matter in this case).

Code:
[root@rescue /]# zpool import -N -R /mnt zroot
[root@rescue /]# ll /mnt
total 0
drwxr-xr-x  2 root  wheel    0 Mar 24 11:44 files
drwxr-xr-x  2 root  wheel    0 Mar 24 11:44 tmp
drwxr-xr-x  3 root  wheel   64 Mar 24 11:51 usr
drwxr-xr-x  7 root  wheel  320 Mar 24 11:44 var
[root@rescue /]# zfs mount zroot/ROOT/default
[root@rescue /]# zfs mount -a
[root@rescue /]# cd /mnt/usr/
[root@rescue /mnt/usr]# ll
total 13
drwxr-xr-x   4 root  wheel   4 Feb 13 11:38 home
drwxr-xr-x  70 root  wheel  87 Feb 13 11:38 ports
drwxr-xr-x   2 root  wheel   2 Feb 13 11:38 src
[root@rescue /mnt/usr]# cd ..
[root@rescue /mnt]# zfs umount zroot/usr
[root@rescue /mnt]# ll usr/
total 159
drwxr-xr-x   2 root  wheel  488 Jan 19 18:00 bin
drwxr-xr-x   2 root  wheel    2 Dec  8  2017 home
drwxr-xr-x  56 root  wheel  346 Jan 19 18:45 include
drwxr-xr-x  10 root  wheel  741 Jan 19 18:45 lib
drwxr-xr-x   7 root  wheel  746 Jan 19 18:00 lib32
drwxr-xr-x   5 root  wheel    5 Dec  5  2020 libdata
drwxr-xr-x   9 root  wheel   67 Jan 19 18:00 libexec
drwxr-xr-x  15 root  wheel   17 Jan 20 06:48 local
drwxr-xr-x   2 root  wheel    2 Jul 21  2017 obj
drwxr-xr-x   2 root  wheel    2 Dec  8  2017 ports
drwxr-xr-x   2 root  wheel  292 Jan 19 18:00 sbin
drwxr-xr-x  31 root  wheel   31 Jan 19 18:45 share
drwxr-xr-x   2 root  wheel    2 Dec  8  2017 src
drwxr-xr-x  15 root  wheel   15 Jul 21  2017 tests
[root@rescue /mnt]#
 
When I mount everything including zroot/usr, /usr/* files beyond datasets in zroot/usr/* are hidden. When I umount zroot/usr, everything gets visible. That's a different behaviour than with zroot/var and zroot/var/*.
You are mounting an empty dataset over an existing directory. That "hides" the data that was in that directory.
 
Back
Top