Importing ZFS Data Pool From Older FreeBSD System
CAUTION: after the following instructions are executed the older system will become unbootable. Please ensure the data is backed up
If we have two FreeBSD systems with ZFS and would like to access data from one on the other we will need to import the ZFS pool in such the way that mount points from the older system do not collide with the new system.
First we will need to import the pool without mounting datasets
sudo zpool import -N tank
Next we will need to ensure the pool unsets mount points for various system file locations to prevent collisions of mount points from two pools
sudo zfs set mountpoint=none tank
sudo zfs set mountpoint=none tank/usr/home
sudo zfs set mountpoint=none tank/usr/jails
sudo zfs set mountpoint=none tank/usr/local
sudo zfs set mountpoint=none tank/usr/obj
sudo zfs set mountpoint=none tank/usr/src
sudo zfs set mountpoint=none tank/usr/ports
sudo zfs set mountpoint=none tank/tmp
sudo zfs set mountpoint=none tank/var
sudo zfs set mountpoint=none tank/var/audit
sudo zfs set mountpoint=none tank/var/log
sudo zfs set mountpoint=none tank/var/mail
sudo zfs set mountpoint=none tank/var/tmp
We will set up the file location where we would like to mount data from the imported pool and configure the pool mount points accordingly
sudo mkdir -p /export/usr/home/max
sudo zfs set mountpoint=/export tank/ROOT/12.0-CURRENT
sudo zfs set mountpoint=/export/usr tank/usr
sudo zfs set mountpoint=/export/usr/home/max tank/usr/home/max
We will need to double check that the pool mount points are set up correctly and ensure they are either set to none or to our non-system mount points
zfs list |grep tank
Once above looks good let us export and re-import the pool and ensure there are no failures or errors when mounting the pool
sudo zpool export tank
sudo zpool import tank
Lastly we will need to reboot the system and check that both pools are imported and mounted
zpool list -o name,health
NAME HEALTH
tank ONLINE
trident ONLINE
zfs mount |grep tank