LXD on LVM pool (How to reduce or resize LXD containers)

Hi!
I have a trouble with sizes of my containers.
LXD on LVM create a containers 10gb size. (Default)
For example i have a container 100gb on another host and i want to copy to new host. I receive an error, because transferring stops after ~9.8gb.
Okay, i change default size pool config lxd to 101gb. But i have a new trouble: when i created a new container (empty, only OS linux), this container weight 161gb, but in fact weight ~1.5gb. “df -h” told me 98gb - empty space in the container. How do reduce the container container on LVM driver storage? And how copying the containers with different space do not touching default size pool lvm. And may be possible create or copy container adding to command “copy” or “launch” a special key “size of this container”?

please help :frowning:

You need to

  1. Stop the container
  2. Check the fs: e2fsck -y /dev/VG/lv
  3. Use resize2fs to reduce the size: resize2fs /dev/VG/lv 80G
  4. Now reduce the size of the volume with lvreduce: lvreduce -L 81G /dev/VG/lv

In most cases the size of the volume must be at least 1% bigger then the filesystem size.
There was some calculation for that, but I don’t remember the exact formula for that.

lvreduce has the -r (resizefs) option, but I haven’t used it :frowning: