Updating storage pool size info

LXD 5.11 on Debian 11.6

I started with the default 30 GB which soon turned out to be insufficient.

I’ve expanded it to 300 GB as below:

truncate -s +270G /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/disks/default.img

losetup -j /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/disks/default.img
/dev/loop4: [2050]:68813228 (/var/snap/lxd/common/lxd/disks/default.img)

losetup -c /dev/loop4

apt install btrfs-progs

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

Even though the size has effectively been increased:

ls -lh /var/snap/lxd/common/lxd/disks/default.img
-rw------- 1 root root 300G Feb 22 13:53 /var/snap/lxd/common/lxd/disks/default.img

lxd init --dump still reports the default 30 GB:

storage_pools:
- config:
    size: 30GiB
    source: /var/snap/lxd/common/lxd/disks/default.img
  description: ""
  name: default
  driver: btrfs

What’s the best / safest way of updating the size info?

You can use lxd sql global to update the database directly (be careful, data loss is only 1 incorrect query away).

If you start with:

lxd sql global 'select storage_pools.name as poolName, storage_pools_config.* from storage_pools_config join storage_pools on storage_pools.id = storage_pools_config.storage_pool_id where storage_pools_config.key = "size" order by storage_pools.id'

This will get you something like:

+----------+-----+-----------------+---------+------+-------+
| poolName | id  | storage_pool_id | node_id | key  | value |
+----------+-----+-----------------+---------+------+-------+
| zfs      | 326 | 2               | 1       | size | 30GiB |
| btrfs    | 313 | 34              | 1       | size | 30GiB |
| lvm      | 321 | 36              | 1       | size | 30GiB |
+----------+-----+-----------------+---------+------+-------+

Then you can use the id value for the specific row you want to update as follows:

lxd sql global 'update storage_pools_config set value = "<new size>GiB" where id = <ID>'
1 Like

like a charm!

1 Like