Resize lvm partitions

Before I forget, I write down the steps to resize my lvm partitions in my Debian laptop.

If the partition to resize is not the root or boot partition I can (re)boot into recovery mode. If it is the root or boot partition I may need to boot a live operating system.

If I want to decrease the partition first I must decrease the file system. Before anything, I should check the filesystem.

umount /usr/local
e2fsck -fy /dev/mapper/yapaque--vg-usr--local
resize2fs /dev/mapper/yapaque--vg-usr--local 29G

Here I must make sure that the new size is large enough so that the data fits.

Then I can reduce the partition to a size that is larger than size of the filesystem used above

lvreduce -L 30G /dev/yapaque-vg/usr-local

Note that the name is different, but I refer to the same partition.

Now I resize again the filesystem to take up all available space within the partition.

resize2fs /dev/mapper/yapaque--vg-usr--local

That’s it.

If I just want to extend the filesystem and I have space in the volume the procedure is slightly shorter. I extend the partition, check the filesystem and extend it to fill the partition.

umount /home
lvextend -L +30G /dev/yapaque-vg/home
e2fsck -fy /dev/mapper/yapaque--vg-home
resize2fs /dev/mapper/yapaque--vg-home
Written on July 9, 2021