How to increase the size of the loop device set at installation


(Rafi59) #1

Hello,

I’m trying to increase the size of the loop device created when installing LXD. I put as answer to the question Size in GB of the new loop device (1GB minimum)[default=15]: 20 but now I want to increase it to 30GB.

How to do this?

Thanks in advance;)

EDIT: I use brtfs


(Stéphane Graber) #2

I believe you should be able to increase the size of the sparse file and then use btrfs filesystem resize to have it pick up the new size.


(Javi) #3

Hi,
I can confirm this works. The steps I did:

  • Stop all containers and unmount the pool
service lxd stop
umount /var/lib/lxd/storage-pools/default
  • Then resize the image:
SIZE=35G
dd if=/dev/zero of=file.img bs=1 count=0 seek=$SIZE
  • Then reboot - maybe service lxd restart fixes it(?)
  • if it is btrfs
btrfs filesystem resize max /var/lib/lxd/storage-pools/default

(or the path of the pool).

Is there a better way to umount/remount the pool?
Thanks


#4

I wasn’t able to do the btrfs filesystem resize max /var/lib/lxd/storage-pools/default command, as btrfs isn’t recognized, running Debian 9 + Snap + LXC&LXD.

root@racktables:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 86.9M 1 loop
loop1 7:1 0 54.5M 1 loop
loop2 7:2 0 54.5M 1 loop
loop3 7:3 0 54.5M 1 loop
loop4 7:4 0 86.6M 1 loop
loop5 7:5 0 86.9M 1 loop
loop6 7:6 0 10G 0 loop /
sda 8:0 0 30G 0 disk
├─sda1 8:1 243M 0 part
└─sda2 8:2 0 29.8G 0 part
sr0 11:0 1 1024M 0 rom
root@racktables:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/loop6 5.0G 3.8G 885M 82% /
none 492K 0 492K 0% /dev
udev 991M 0 991M 0% /dev/tty
tmpfs 100K 0 100K 0% /dev/lxd
tmpfs 100K 0 100K 0% /dev/.lxd-mounts
tmpfs 1003M 0 1003M 0% /dev/shm
tmpfs 1003M 8.2M 994M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1003M 0 1003M 0% /sys/fs/cgroup
tmpfs 201M 0 201M 0% /run/user/0

It sees that it’s 10G, but /dev/loop6 is still 5GB? This is after a reboot.
Please advice, thank you!

EDIT:

root@noc-01:~# lxc storage show default
config:
size: 5GB
source: /var/snap/lxd/common/lxd/disks/default.img

On my host server, still says 5G…


(Javi) #5

If you don’t have the btrfs command is probably because your pool is not btrfs (which is the theme of the thread).
Probably you have zfs.
Also, as you have snap version, the paths are different.
Sorry, I don’t use snap or zfs, can’t help you.


#6

Hi Javi_Perez.

It is in fact btrfs:

root@noc-01:~# lxc storage list
±--------±------------±-------±-------------------------------------------±--------+
| NAME | DESCRIPTION | DRIVER | SOURCE | USED BY |
±--------±------------±-------±-------------------------------------------±--------+
| default | | btrfs | /var/snap/lxd/common/lxd/disks/default.img | 9 |
±--------±------------±-------±-------------------------------------------±--------+

But since Snap seems different, I’ll create a new topic, thanks! :slight_smile:


#7

btrfs with the LXD snap means that the snap package of LXD has internally all the btrfs utilities it needs to do its own work.

Which means that if you want to specifically resize yourself, you would need to install btrfs-tools so that you can use the tools yourself on the host.


(Stéphane Graber) #8

Indeed, our snap is sneaky that way, it includes all the needed tools so LXD can use them but they’re not easily available for you to manually use.

So the solution here would indeed be to install those btrfs tools yourself. Note that you’ll also need to use /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/default as the path to your btrfs subvol so you see what the LXD daemon sees.


(Sharpaper) #9

Sorry do you mean that the correct commands are

umount /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/default

and

btrfs filesystem resize max /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/default

?