ZFS help migrating custom ZFS layout to the default one

I installed FreeBSD with very custom ZFS layout to try out manual steps in shell. It served no other purposes. Now I want migrate my pool back to the default ZFS layout provided in default images. https://cgit.freebsd.org/src/tree/release/tools/vmimage.subr#n215
vixen/os/main is my "/" I want to preserve /music and /torrent, of course, as well as /home. Can this migration be achieved without reinstalling whole system from scratch? default layout appears well thought and also is supported by bectl
current layout:

NAME USED AVAIL REFER MOUNTPOINT
vixen 248G 643G 96K none
vixen/home 96K 643G 96K /usr/home
vixen/music 108G 643G 108G /music
vixen/os 62.4G 643G 96K none
vixen/os/main 62.4G 643G 62.4G none
vixen/torrent 78.1G 643G 78.1G /torrent
 
Can this migration be achieved without reinstalling whole system from scratch?
It can be done, unless the current installations 'ashift' (pool sector size exponent) property has a different value than the default zfsboot installation (=12). 'ashift' is a pool creation zpoolprops(7) property, which can't be modified after a pool is created.

Check 'ashift' as 'root' user: zdb -C <pool_name> | grep ashift

I believe the best template for a zpool and data default layout creation and their properties is a install log file from a menu guided installation. Adapt dataset names accordingly.

Redacted and slightly modified /var/log/bsdinstall_log from my notes for a custom non-menu guided, or semi-menu guided installation. You can cherrypick the relevent datasets and their properties:
Rich (BB code):
zpool create -o ashift=12 -o altroot=/mnt -O compression=lz4 -O atime=off -m none zroot ada0

zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ zroot/ROOT/default

zfs create -o mountpoint=/home zroot/home
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp

zfs create -o mountpoint=/usr -o canmount=off zroot/usr
zfs create -o setuid=off zroot/usr/ports

zfs create zroot/usr/src

zfs create -o mountpoint=/var -o canmount=off zroot/var
zfs create -o exec=off -o setuid=off zroot/var/audit

zfs create -o exec=off -o setuid=off zroot/var/crash
zfs create -o exec=off -o setuid=off zroot/var/log

zfs create -o atime=on zroot/var/mail
zfs create -o setuid=off zroot/var/tmp

zfs set mountpoint=/zroot zroot

chmod 1777 /mnt/tmp/

mkdir -p /mnt/var/tmp
chmod 1777 /mnt/var/tmp

zpool set bootfs=zroot/ROOT/default zroot

mkdir -p /mnt/boot/zfs

zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot

zfs set canmount=noauto  zroot/ROOT/default

In a worst case scenario (re-installation of the system), the datasets you want to preserve can be zfs-snapshot(8) and zfs-send(8) (redirected into a file or send to another backup ZFS). After the new system is running zfs-receive(8).
 
Back
Top