Move storage/disk between lxd servers

I am trying to move a disk that contains a storage pool and containers from one LXD server to another.

I can’t use copy or move in my case. I need to move the physical disk.

My thought was that I do the following steps:

  • on the new server create a storage pool
  • mount the new drive on the location of the new storage pool
  • start the containers

Unfortunately it seems to be a bit more tricky than that. lxd list doesn’t show the containers from the new device.

I made sure that the links in /var/lib/lxd/containers and /var/lib/lxd/storage-pools are available but no success.
Then I saw in the storage-pool config that the used-by: entry is empty. But adding the containers doesn’t help either. The entry gets lost after I saved the file.

Using dir driver no ZFS or BTRFS.

Appreciate your help!

LXD uses a database to keep track of everything. Simply moving the files around won’t do it.

What LXD version are you running?

Newer LXD releases have a “lxd import” command that’s used to deal with those cases.
Make sure everything is back into place and then run “lxd import NAME” for every container you’d like to re-import from disk.

Thanks for that info!
I found the lxd.db file and was already suspecting it to be the reason why it’s not working.

I am on the latest version 2.18. Gonna give the import command a try.

Do I also need to create those files in security/apparmor and security/seccomp or will import do that for me?

Nope, the security files are re-generated whenever a container starts.