Expand lxd’s default btrfs storage pool

To expand lxd’s default btrfs storage pool:

# lxc storage list
+---------++--------+--------------------------------+---------+
|  NAME   || DRIVER |             SOURCE             | USED BY |
+---------++--------+--------------------------------+---------+
| default || btrfs  | /var/lib/lxd/disks/default.img | 2       |
+---------++--------+--------------------------------+---------+

Once you know the location of the disk image, you must first expand the actual .img file.

# truncate -s +500G /var/lib/lxd/disks/default.img

Reboot the server to effect the changes to the loopback device (too lazy to figure out how to do this online – losetup -c didn’t work.)

Then, use btrfs to resize the filesystem within the .img

# btrfs filesystem resize max /var/lib/lxd/storage-pools/default

Reboot the server again to effect the changes to the loopback device.

You should see the new disk size on both host loopback device and container.

This doesn’t seem to update the configuration file within lxd so the storage pool will still say the old size configuration value. I’m not sure if this has any effect though, since the btrfs storage mode seems to be pretty much passthrough.

btrfs resize documentation: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Storage_Administration_Guide/ch06s03.html

GitHub issue: https://github.com/lxc/lxd/issues/4847

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s