How to resize storage#

If you need more storage, you can increase the size of your storage pool or your storage volume. In some cases, it is also possible to reduce the size of a storage volume.

Grow a storage pool#

To increase the size of a storage pool, follow these general steps:

  1. Grow the size of the storage on disk.

  2. Let the file system know of the size change.

See the specific commands for different storage drivers below.

Enter the following commands to grow a loop-backed Btrfs pool by 5 Gigabytes:

sudo truncate -s +5G <LXD_lib_dir>/disks/<pool_name>.img
sudo losetup -c <loop_device>
sudo btrfs filesystem resize max <LXD_lib_dir>/storage-pools/<pool_name>/

Replace the following variables:

<LXD_lib_dir>

/var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/ if you are using the snap, or /var/lib/lxd/ otherwise.

<pool_name>

The name of your storage pool (for example, my-pool).

<loop_device>

The mounted loop device that is associated with the storage pool image (for example, /dev/loop8). To find your loop device, enter losetup -j <LXD_lib_dir>/disks/<pool_name>.img. You can also use losetup -l to list all mounted loop devices.

Resize a storage volume#

To resize a storage volume, set its size configuration:

lxc storage volume set <pool_name> <volume_name> size <new_size>

Important

  • Growing a storage volume usually works (if the storage pool has sufficient storage).

  • Shrinking a storage volume is only possible for storage volumes with content type filesystem. It is not guaranteed to work though, because you cannot shrink storage below its current used size.

  • Shrinking a storage volume with content type block is not possible.