On space constrained system, can the LVM root partition be made thin instead of thick ?

shodan

Active Member
Sep 1, 2022
215
58
33
Hi,

I have a small SSD on this small proxmox computer
and I notice that the root partition is quite big

Code:
Filesystem           1K-blocks     Used Available Use% Mounted on
/dev/mapper/pve-root  98497780 38828088  54620144  42% /

It has a lot of empty space and lvs reveals that it is a thick partition, not a thin one


Code:
data                    pve           twi-aotz--    ??.??g
root                    pve           -wi-ao----    96.00g
swap                    pve           -wi-ao----     8.00g

I understand in some cases, having a thick partition to ensure filling the pool doesn't crash the host OS is an acceptable sacrifice of all that empty space.

But in my particular case, I need the space more than I need the buffer space.

I promise I will be careful not to overflow my storage device !

So, anyway, my plan for now..

Would be to create a LVM thin volume called root2
format this partition as ext4 and mount to /mnt/root2/
cp -ra /* /mnt/root2/

then edit /etc/fstab to mount root2 to /

Now this is a little too optimistic I think... and I will need to do something at least about /boot/efi/EFI/proxmox/grub.cfg because there is an UUID of the old partition in there.

I also asked chatgpt about this, and instead of using cp -ra , it suggest using

Code:
rsync -aHAXx /* /mnt/root2 --exclude=/mnt/root2 --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/run

Which I don't really trust that it did all the excludes it needed to do. I also am suspicious that it won't break some file permission or other metadata ...

It also suggests to run chroot into the copied filesystem and run update grub in there

something like this

Code:
for dir in dev proc sys run; do mount --bind /$dir /mnt/root2/$dir; done
chroot /mnt/root2 /bin/bash
update-initramfs -u -k all
update-grub
exit

Now, I'm not too worried to bork this system,
but I would appreciate some guidance if anyone here knows how to do this cleaner than this ?

In any case, I will report the results back here