Disk set and increase

for lvm container I have set disk size by this command

#lxc config device set con3 root size 100GB

After reboot, the container works fine and disk size set. But when I am trying to increase the size by the below command it shows an error

#lvextend -L +150G my-lvm/cont3
Volume group “my-lvm” not found
Cannot process volume group my-lvm

OR

lxc config device override con3 root size 200GB
Error: The device already exists

Where is my fault? My lxd on zfs storage

You should never use LVM tools directly with LXD volumes, as LXD will not know about the operation and its state will get out of sync, potentially causing issues.

Why did you change from lxc config device set (as in the first command) to lxc config device override (in the second command)? The first command using set would have allowed you to change the size to 200GB.

Yes, I have 1st generate “lxc config set” command and reboot my container. after reboot I have checked the size it is ok. Then I am again trying to increase my container disk by “lxc config device override” for testing purposes but it doesn’t work. What is the procedure to again increase container lvm disk?

lxc config device set con3 root size 200GB

Then If I want to increase the disk from 200GB to 500GB what should I do?

1 Like
lxc config device set con3 root size 500GB

When I am trying to increase from 200GB to 500GB It shows this

root@lxd1:~# lxc config device set con4 root size 500GB
Error: The device doesn’t exist

If it is a new container (using the profile’s disk), then use override, that will copy the root disk config from the profile into the container and override the size property.

lxc config device override con3 root size 200GB

Then on subsequent modifications use the set command:

lxc config device set con3 root size 500GB

lxc launch ubuntu:20.04 con4 -p my-lvm -s my-lvm its on my lvm now?

When providing the -s flag to lxc init or lxc launch, it will override the root device at create time to modify it’s storage pool. So you just need to use lxc config device set con4 root size after that.

root@lxd1:~# lxc launch ubuntu:20.04 con4 -p my-lvm -s my-lvm
Creating con4
Starting con4
root@lxd1:~# lxc config device override con4 root size 200GB
Error: The device already exists
root@lxd1:~# lxc config device set con4 root size 200GB
root@lxd1:~# lxc exec con4 bash
root@con4:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/my-lvm/containers_con4 184G 1014M 175G 1% /
none 492K 4.0K 488K 1% /dev
udev 32G 0 32G 0% /dev/tty
tmpfs 100K 0 100K 0% /dev/lxd
tmpfs 100K 0 100K 0% /dev/.lxd-mounts
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 6.3G 188K 6.3G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
root@con4:~# reboot
root@con4:~# root@lxd1:~# lxc exec con4 bash
root@con4:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/my-lvm/containers_con4 184G 1.1G 175G 1% /
none 492K 4.0K 488K 1% /dev
udev 32G 0 32G 0% /dev/tty
tmpfs 100K 0 100K 0% /dev/lxd
tmpfs 100K 0 100K 0% /dev/.lxd-mounts
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 6.3G 192K 6.3G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
root@con4:~# exit
exit
root@lxd1:~# lxc config device override con4 root size 300GB
Error: The device already exists

I need to know how can I extend the conatiner LVM disk again from 200GB to 300GB?

I can’t remeber how I did it. but this command now doesn’t work

root@lxd1:~# lvextend -L +50G my-lvm/containers_test
Size of logical volume my-lvm/containers_test changed from 10.05 GiB (2573 extents) to 60.05 GiB (15373 extents).
Logical volume my-lvm/containers_test successfully resized.