Is there a way to shrink/reduce default.img zpool?

Is there a way to shrink/reduce default.img zpool?

When I setup lxd I choose too much size for default image based pool

lxc storage info default -v
info:
  description: ""
  driver: zfs
  name: default
  space used: 570.97MB
  total space: 28.61GB
used by:
  images:
  - 90e2d54028ddfe65c31605bb9f0cece65752d05ff385989f3eda6b38d92fab5a
  profiles:
  - default

Can i shrink
/var/snap/lxd/common/lxd/disks/default.img
to 5GB without LXD disruption
regards

You can’t shrink a ZFS pool unfortunately.
What you may be able to do though is enable TRIM on it so it may release some used space back.

You’ll need the ZFS tools, then you should be able to do:

  • zpool set default autotrim on
  • zpool trim default

This may take a little while, zpool status should give you some indication of it happening, then look at your default.img and hopefully it will be quite a bit smaller.

Ok my main concern is full backup of LXD
/var/snap/lxd/common/lxd size is about 1GB without default.img 28GB
IMHO those image based pools should be placed outside of /var/snap/lxd/common/lxd

Is there a safe way to remove this default zpool from within LXD?

regards

Something like this should let you delete it:

  • “lxc delete” of all instances using it
  • lxc profile device remove default root
  • lxc storage delete default

Then re-create with:

  • lxc storage create default zfs size=5GiB (or whatever size you want)
  • lxc profile device add default root disk pool=default path=/

THank you

I wonder if LXD must have pool named “default” ?? If YES why?

Can I remove default image pool - as You described - and set ZFS disk one as DEFAULT?

regards

You can name the pool whatever you want, but LXD needs to have a storage pool for instances to be stored on.

A pool can be backed by a physical disk/partition or consume a dataset from an existing ZFS pool on the system, all of this can be done through lxd init too.

Sure I Have now 4 LXD pools with default on

+---------+--------+--------------------------------------------+-------------+---------+
|  NAME   | DRIVER |                   SOURCE                   | DESCRIPTION | USED BY |
+---------+--------+--------------------------------------------+-------------+---------+
| default | zfs    | /var/snap/lxd/common/lxd/disks/default.img |             | 2       |
+---------+--------+--------------------------------------------+-------------+---------+
| pool0   | zfs    | zpool0                                     |             | 4       |
+---------+--------+--------------------------------------------+-------------+---------+
| pool1   | zfs    | zpool1                                     |             | 25      |
+---------+--------+--------------------------------------------+-------------+---------+
| pool2   | zfs    | zpool2                                     |             | 21      |
+---------+--------+--------------------------------------------+-------------+---------+

If I remove default /var/snap/lxd/common/lxd/disks/default.img
then
I must set up for example pool0 as default?
or can I leave it as it is

Summed up: Is there definition of “default pool in LXD” ? if YES why?

regards

Okay, you don’t have to put a pool in the default profile but if you don’t, you’ll have to pass --storage every time you create a new instance.

OK so If I understand You
When I change in profile default

  root:
    path: /
    pool: default
    type: disk
to
  root:
    path: /
    pool: pool0
    type: disk

that’s it?

regards

yep

thx!