Migrate LXD (2.0.x) ZFS storage pool to new ZFS pool

by Christian Lønaas, 2018-07-31

I've done this a few times now, and when you know how to do it, it's a breeze.

Posting the "recipe" here, for my self and anyone who might need it.

Should be pretty self explanatory for those with a little experience with ZFS.

Obviously, after starting LXD after migrating, you should test if everything is OK before destroying the old dataset.

(you will need the packages sqlite3 and mbuffer, mbuffer can be omitted at the cost of some speed)

zpool create -f -o ashift=12 newpool ata-Samsung_SSD_860_EVO_250GB_S3YJNB0K581614J
systemctl stop lxd.service lxd.socket
zfs snapshot -r oldpool/lxd@migrate
zfs send -R oldpool/lxd@migrate | mbuffer -q -s 128k -m 1G | zfs receive -vF newpool/lxd
zfs list | grep oldpool/lxd | awk '{print $1}' | while read line; do zfs set mountpoint=none $line; done
zfs list -r newpool/lxd -t snapshot | grep '@migrate' | awk '{print $1}' | while read line; do zfs destroy $line; done
sqlite3 /var/lib/lxd/lxd.db "UPDATE config SET value='newpool/lxd' WHERE value='oldpool/lxd';"
systemctl start lxd.socket lxd.service
zfs destroy -r oldpool/lxd

Ubuntu 18.04 ZFS on root NetworkManager gotcha

by Christian Lønaas, 2018-07-10

When installing Ubuntu with root on ZFS (following this great guide), I soon discovered that something was amiss with the networking. Wi-fi worked fine, but my mobile broadband failed to connect, and NetworkManager didn't respond when I plugged in an ethernet cable.

After literally HOURS of troubleshooting (beginning in the wrong end with the mobile broadband), I stumbled across this bug report. Sounds familiar, I installed the ZFS root with a chroot (debootstrap). Thankfully, the comments have the solution.

Create an empty file, and restart stuff.

$ sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
$ sudo systemctl restart NetworkManager ModemManager

Voilà! Problem solved.