Moving containers to a new zfs pool, with all zfs snapshots

I need to move an entire lxc installation from one zfs pool to another, ideally preserving existing snapshots. I expected I could use zfs send -R... followed by updating the lxc config to point to the new pool (after shutting down lxd / containers).

When I do that, I get “Pool source cannot be changed when not in pending state” which was recently added at https://github.com/lxc/lxd/pull/8235. I’m not finding any docs enumerating what all the states are (pending what?) or how to transition between them.

In practice, it sounds like moving storage outside of lxc commands is unsupported. However, there’s a variety of old posts detailing updating the sqlite database by hand, which is fine by me. I stopped the lxd daemon, ran /var/snap/lxd/common/lxd/database/global/db.bin, and ran update storage_pools_config set value='rpool/lxc' where id=%% for each row with the old pool name. However, on starting lxd again lxd storage edit still shows the old pool name. Is there something else I need to update for this to work?

One of the posts I found was Moving LXD Containers Between ZFS Pools but the linked article at http://blog.stonie.us/moving-lxd-containers-between-zfs-pools.html is down and it’s not cached by Google or the Wayback machine. If anyone remembers what it said, that’d be helpful!

Otherwise, if there’s a way to send lxc containers and all zfs snapshots (even those created outside of lxc) I can resend the data if that’s a better solution.

I was able to get this working by using the lxd sql command as documented at https://linuxcontainers.org/lxd/docs/master/database to update the storage pool config.

1 Like

Yes that is a fine approach, as we do not support updating the pool’s source via LXD as one would expect LXD to then actually action the move request which we do not currently support.