Adjusting my ZFS filesystems to conform with standard FreeBSD boot environments

Get FreeBSD 12.2 mfsBSD (because that matches the OS on slocum), burn it to a thumb drive using OSX.

NOTE: the following didn’t work. I wound up not having the right values in /lib and /var/db/

I don’t know what I did wrong, but I did manage to fix them up afterwards. I suspect that I still had zroot/usr mounted and did not notice.

I will keep my notes here for future reference but I warn you that this did not work and further work was required.

[root@mfsbsd ~]# zpool import -R /mnt zroot 
cannot import 'zroot': pool was previously in use from another system.
Last accessed by slocum.int.unixathome.org (hostid=8aa2e4fe) at Sun May 30 17:57:37 2021
The pool can be imported, use 'zpool import -f' to import the pool.
[root@mfsbsd ~]# zpool import -fR /mnt zroot 
[root@mfsbsd ~]# 
[root@mfsbsd ~]# zfs list
NAME                  USED  AVAIL  REFER  MOUNTPOINT
zroot                13.2G   192G    88K  /mnt/zroot
zroot/ROOT            305M   192G    88K  none
zroot/ROOT/default    305M   192G   285M  /mnt
zroot/tmp            6.88M   192G   160K  /mnt/tmp
zroot/usr            3.19G   192G  2.36G  /mnt/usr
zroot/usr/old_local   677M   192G   677M  /mnt/usr/old_local
zroot/var            9.54G   192G  8.88G  /mnt/var
zroot/var/audit        88K   192G    88K  /mnt/var/audit
zroot/var/empty        88K   192G    88K  /mnt/var/empty
zroot/var/log         172M   192G  24.1M  /mnt/var/log
zroot/var/tmp        1.75M   192G   844K  /mnt/var/tmp
[root@mfsbsd ~]# 

The wrong system:

[root@mfsbsd ~]# zfs list -o canmount,mounted,mountpoint,name
CANMOUNT  MOUNTED  MOUNTPOINT          NAME
      on      yes  /mnt/zroot          zroot
      on       no  none                zroot/ROOT
  noauto       no  /mnt                zroot/ROOT/default
      on      yes  /mnt/tmp            zroot/tmp
      on      yes  /mnt/usr            zroot/usr
     off       no  /mnt/usr/old_local  zroot/usr/old_local
      on      yes  /mnt/var            zroot/var
      on      yes  /mnt/var/audit      zroot/var/audit
      on      yes  /mnt/var/empty      zroot/var/empty
      on      yes  /mnt/var/log        zroot/var/log
      on      yes  /mnt/var/tmp        zroot/var/tmp
[root@mfsbsd ~]# 

A correct system:

[dan@knew:~] $ zfs list -ro canmount,mounted,mountpoint,name zroot
CANMOUNT  MOUNTED  MOUNTPOINT  NAME
      on      yes  /zroot      zroot
      on       no  none        zroot/ROOT
      on      yes  /           zroot/ROOT/default
      on      yes  /tmp        zroot/tmp
     off       no  /usr        zroot/usr
      on      yes  /usr/local  zroot/usr/local
     off       no  /var        zroot/var
      on      yes  /var/audit  zroot/var/audit
      on      yes  /var/crash  zroot/var/crash
      on      yes  /var/empty  zroot/var/empty
      on      yes  /var/log    zroot/var/log
      on      yes  /var/mail   zroot/var/mail
      on      yes  /var/tmp    zroot/var/tmp
[dan@knew:~] $ 

Notice how zroot/usr and zroot/var differ with CANMOUNT and MOUNTED.

I’m going to fix that on the old system.

[root@mfsbsd ~]# zfs snapshot zroot/usr@for_copy
[root@mfsbsd ~]# zfs send zroot/usr@for_copy | zfs recv zroot/NEW_USER

Notice how I create NEW_USER whereas I wanted NEW_USR… that’s just how I pronounce the mount point

[root@mfsbsd /mnt]# ls -l usr
total 119
drwxr-xr-x   2 root  wheel  526 Apr 12 16:18 bin
drwxr-xr-x   4 root  wheel    5 Oct  3  2014 home
drwxr-xr-x  56 root  wheel  342 Dec  8 22:33 include
drwxr-xr-x  11 root  wheel  730 May 28 17:32 lib
drwxr-xr-x   5 root  wheel    9 Jun 10  2020 lib32
drwxr-xr-x   5 root  wheel    5 Jun 10  2020 libdata
drwxr-xr-x   9 root  wheel   68 Dec  8 22:34 libexec
drwxr-xr-x  20 root  wheel   22 May 21 18:57 local
drwxr-xr-x   2 root  wheel    2 Jun  8  2020 obj
drwxr-xr-x   2 root  wheel    2 May  3  2013 ports
drwxr-xr-x   2 root  wheel  307 Feb 24 13:26 sbin
drwxr-xr-x  30 root  wheel   30 Dec  8 22:33 share
drwxr-xr-x   2 root  wheel    2 Jun  8  2020 src
drwxr-xr-x  15 root  wheel   18 Jun  7  2020 tests
[root@mfsbsd /mnt]# mount | grep usr
zroot/usr on /rw/mnt/usr (zfs, local, noatime, nfsv4acls)
[root@mfsbsd /mnt]# umount zroot/usr
[root@mfsbsd /mnt]# ls -l usr
total 0
[root@mfsbsd /mnt]# cd /mnt/zroot/NEW_USER
[root@mfsbsd /mnt/zroot/NEW_USER]# ls
bin	home	include	lib	lib32	libdata	libexec	local	obj	ports	sbin	share	src	tests
[root@mfsbsd /mnt/zroot/NEW_USER]# cp -a * /mnt/usr
[root@mfsbsd /mnt/zroot/NEW_USER]# ls /mnt/usr
bin	home	include	lib	lib32	libdata	libexec	local	obj	ports	sbin	share	src	tests

Now for /var

[root@mfsbsd /mnt/zroot/NEW_USER]# cd /mnt/var
[root@mfsbsd /mnt/var]# ls
[root@mfsbsd /mnt/var]# 

NOTE what I forgot to do here was umount zroot/usr before I started the copy. I had to come back to that later. When I did, there were three additional messages in the copy output:

cp: utimensat: /mnt/var/empty: Read-only file system
cp: chmod: /mnt/var/empty: Read-only file system
cp: chflags: /mnt/var/empty: Read-only file system
[root@mfsbsd /mnt/var]# cd /mnt/zroot/NEW_VAR
[root@mfsbsd /mnt/zroot/NEW_VAR]# ls
account		audit		cache		db		heimdal		mail		named		run		tmp
agentx		authpf		crash		empty		lib		msgs		net-snmp	rwho		unbound
at		backups		cron		games		log		munin		preserve	spool		yp
[root@mfsbsd /mnt/zroot/NEW_VAR]# 
[root@mfsbsd /mnt/zroot/NEW_VAR]# cp -a * /mnt/var/
cp: run/devd.pipe is a socket (not copied).
cp: run/devd.seqpacket.pipe is a socket (not copied).
cp: spool/postfix/private/verify is a socket (not copied).
cp: spool/postfix/private/local is a socket (not copied).
cp: spool/postfix/private/relay is a socket (not copied).
cp: spool/postfix/private/bounce is a socket (not copied).
cp: spool/postfix/private/rewrite is a socket (not copied).
cp: spool/postfix/private/lmtp is a socket (not copied).
cp: spool/postfix/private/proxymap is a socket (not copied).
cp: spool/postfix/private/discard is a socket (not copied).
cp: spool/postfix/private/error is a socket (not copied).
cp: spool/postfix/private/retry is a socket (not copied).
cp: spool/postfix/private/proxywrite is a socket (not copied).
cp: spool/postfix/private/defer is a socket (not copied).
cp: spool/postfix/private/trace is a socket (not copied).
cp: spool/postfix/private/smtp is a socket (not copied).
cp: spool/postfix/private/tlsmgr is a socket (not copied).
cp: spool/postfix/private/virtual is a socket (not copied).
cp: spool/postfix/private/scache is a socket (not copied).
cp: spool/postfix/private/anvil is a socket (not copied).
cp: spool/postfix/public/postlog is a socket (not copied).
cp: spool/postfix/public/flush is a socket (not copied).
cp: spool/postfix/public/cleanup is a socket (not copied).
cp: spool/postfix/public/qmgr is a socket (not copied).
cp: spool/postfix/public/showq is a socket (not copied).
cp: spool/postfix/public/pickup is a socket (not copied).
[root@mfsbsd /mnt/zroot/NEW_VAR]# 
[root@mfsbsd /mnt/zroot/NEW_VAR]# zfs list
NAME                  USED  AVAIL  REFER  MOUNTPOINT
zroot                24.4G   181G    96K  /mnt/zroot
zroot/NEW_USER       2.36G   181G  2.36G  /mnt/zroot/NEW_USER
zroot/NEW_VAR        8.88G   181G  8.88G  /mnt/zroot/NEW_VAR
zroot/ROOT            305M   181G    88K  none
zroot/ROOT/default    305M   181G   285M  /mnt
zroot/tmp            6.88M   181G   160K  /mnt/tmp
zroot/usr            3.19G   181G  2.36G  /mnt/usr
zroot/usr/old_local   677M   181G   677M  /mnt/usr/old_local
zroot/var            9.54G   181G  8.88G  /mnt/var
zroot/var/audit        88K   181G    88K  /mnt/var/audit
zroot/var/empty        88K   181G    88K  /mnt/var/empty
zroot/var/log         172M   181G  24.1M  /mnt/var/log
zroot/var/tmp        1.75M   181G   844K  /mnt/var/tmp

Turn CANMOUNT off for those two filesystems:

[root@mfsbsd /mnt/zroot/NEW_VAR]# zfs set canmount=off zroot/usr zroot/var
[root@mfsbsd /mnt/zroot/NEW_VAR]# zfs list -o canmount,mounted,mountpoint,name
CANMOUNT  MOUNTED  MOUNTPOINT           NAME
      on      yes  /mnt/zroot           zroot
      on      yes  /mnt/zroot/NEW_USER  zroot/NEW_USER
      on      yes  /mnt/zroot/NEW_VAR   zroot/NEW_VAR
      on       no  none                 zroot/ROOT
  noauto       no  /mnt                 zroot/ROOT/default
      on      yes  /mnt/tmp             zroot/tmp
     off       no  /mnt/usr             zroot/usr
     off       no  /mnt/usr/old_local   zroot/usr/old_local
     off       no  /mnt/var             zroot/var
      on       no  /mnt/var/audit       zroot/var/audit
      on       no  /mnt/var/empty       zroot/var/empty
      on       no  /mnt/var/log         zroot/var/log
      on       no  /mnt/var/tmp         zroot/var/tmp
[root@mfsbsd /mnt/zroot/NEW_VAR]# 
[root@mfsbsd /]# zpool export zroot
[root@mfsbsd /]# 
Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top