Change Storage (Size and Driver)

Good afternoon,

I have a Debian 10 as host via LXD of several Debian, the problem is that in its day a Pool of 17GB LVM was made t now I do not know how to expand it, I also need to know how to pass it to ZFS that from what I have seen in forums and others Is it better and easier to manipulate than the pool in LVM, which you recommend, can you switch from LVM to ZFS?

Thank you very much for your help!

Hi!

You can create a new storage pool, which is bigger in size, and then move all the containers there.
Finally, switch to the new storage pool as the default one, and release the original pool.

For this to work, you need to have a recent LXD (i.e. the snap package with channel stable and not the LXD 3.0.x). To verify, run lxc move --help and check whether there is a --storage option.

It does not matter whether you use LVM or ZFS or btrfs. They all work. Since you use Debian and has ZFS only through DKMS, you may safely choose LVM or btrfs.

Here we go.

$ lxc storage list
+------+-------------+--------+--------+---------+
| NAME | DESCRIPTION | DRIVER | SOURCE | USED BY |
+------+-------------+--------+--------+---------+
| lxd  |             | zfs    | lxd    | 73      |
+------+-------------+--------+--------+---------+
$ lxc storage create secondpool zfs size=2GB
Storage pool secondpool created
$ lxc stop mycontainer
$ lxc move mycontainer mycontainer-tobemoved
$ lxc move mycontainer-tobemoved mycontainer --storage=secondpool
$ lxc start mycontainer

Once you have moved all the containers to the new storage pool, you can remove the original storage pool and keep using the new one. With lxc storage list, you can see how many containers are located in each pool.

Thanks for answering and helping me, when creating the ZFS pool I get the following error:

Error: The “zfs” tool is not enabled

And when you try to install it with apt-get you can’t find it in the repositories but in the snap they are.

I was really thinking of going to ZFS because in the documentation they recommend it in front of LVM but I don’t know whether to expand the size of the LVM that I have or change to ZFS

The ZFS error is that you do not have the zfsutils-linux package installed.
If you do not have the ZFS kernel support in the kernel, then it might be simpler to use btrfs.

Note that for your lvm storage pool you are currently using a loop file instead of a partition.
If you search this forum you will find similar discussions that used truncate to expand a file and then use a filesystem tool to fix the inner filesystem. This might or might not apply to LVM.

My suggestion though is to create a new storage pool with a storage backend of your choice, and move over all the containers.
Note that to create a storage pool to use a partition or drive, you specify the device name. Otherwise, it will use a loop file.

Good again, so I see the option to move is only in versions of lxd 3.2 or later but I can not update with snap …

I also thought about stopping the container and making a copy but I don’t see clearly the commands in the documentation.

Is there any way to upgrade via snap to a later version of lxd? Do you have any kind of problem at the container level?

Thank you very much, greetings!

First, let’s make sure you are using the snap package of LXD.

$ which lxc
/snap/bin/lxc

$ which lxd
/snap/bin/lxd

Then, we check which channel you are tracking for the LXD snap package. In my case, I am tracking stable, which means LXD 3.18. For your case, it says 3.0.4, which means you are likely tracking 3.0/stable.

$ snap info lxd
...
tracking:     stable
refresh-date: 2 days ago, at 04:04 UTC
channels:
  stable:         3.18        2019-11-05 (12317) 57MB -
  candidate:      3.18        2019-11-05 (12354) 57MB -
  beta:           ↑                                   
  edge:           git-e7f766f 2019-11-09 (12406) 57MB -
  3.18/stable:    3.18        2019-11-05 (12317) 57MB -
  3.18/candidate: 3.18        2019-11-05 (12354) 57MB -
  3.18/beta:      ↑                                   
  3.18/edge:      ↑                                   
  3.17/stable:    3.17        2019-10-10 (11985) 57MB -
  3.17/candidate: 3.17        2019-10-10 (12071) 57MB -
  3.17/beta:      ↑                                   
  3.17/edge:      ↑                                   
  3.0/stable:     3.0.4       2019-10-10 (11348) 55MB -
  3.0/candidate:  3.0.4       2019-10-10 (11348) 55MB -
  3.0/beta:       ↑                                   
  3.0/edge:       git-81b81b9 2019-10-10 (11362) 55MB -
  2.0/stable:     2.0.11      2019-10-10  (8023) 28MB -
  2.0/candidate:  2.0.11      2019-10-10  (8023) 28MB -
  2.0/beta:       ↑                                   
  2.0/edge:       git-c7c4cc8 2019-10-10  (9257) 26MB -
installed:        3.18                   (12317) 57MB -
$ 

You can upgrade your versions to 3.18 (but cannot downgrade anymore back to 3.0) by using

$ snap switch lxd --channel=stable
$ snap refresh

Good again

Finally I have passed all the containers to a pool btrfs and updated the LXD via snap as you explained to me, thank you very much for your help!