Importing Existing BTRFS Storage Pool [Block Storage] after Server Rebuild

Required information

  • Distribution: Debian
  • Distribution version: 10
  • The output of “lxc info” or if that fails:
    • Kernel version: 4.19.0-14-amd64
    • LXC version: 4.12
    • LXD version: 4.12
    • Storage backend in use: BTRFS

Issue description

Hi, I did a rebuild of the server I was using to run LXD containers on. The LXD storage pool is a BTRFS pool from block storage, which is essentially just an LVM volume with a BTRFS filesystem on it. I rebuild the root filesystem and want to use the existing LXD storage pool still available.

The storage pool name: containers
The storage pool logical volume location: /services/lxd

How do use an existing BTRFS storage pool which is a logical volume or block device?

Your assistance would be greatly appreciated.

Kind Regards

Hi Everyone,

I need to rebuild this server tonight and I really need your assistance. Please let me know if there is any further information you require in order to assist me?

Thanks

Well, I don’t know what exactly you plan, but I think essentially the btrfs and lvm documentation and https://linuxcontainers.org/lxd/docs/master/storage#btrfs will be helpful for you.

Is the /services/lxd directory mounted on the host already?

Make sure you have a backup of /services/lxd before proceeding.

Have you tried creating a storage pool referencing that directory as a source, e.g.:

lxc storage create mypool btrfs source=/services/lxd

Then doing a lxd import for each instance may work.

E.g.

sudo lxd import myinstance

@stgraber does this feasibly work?

You shouldn’t use lxc storage create before lxd import. It will fail due to the source not being empty.

Instead you need to enter the snap’s mount namespace and mount the storage pool where it once was under /var/snap/lxd/common/lxd/storage-pools.

So first nsenter --mount /run/snapd/ns/lxd.mnt and then from that shell mount -o bind /services/lxd /var/snap/lxd/common/lxd/storage-pools/default/ assuming the store pool was called default, otherwise change as needed.

Once it’s mounted there, lxd import should behave properly and will recreate the storage pool in the database when importing its first container.

1 Like