Resizing LVM-volumes with an ext4 filesystem

If you have multiple partitions and one of them is full, you can shrink some of them and extend the one needed. First you need to reduce the filesystem and then reduce the partition. Be sure it is unmounted and do a filesystem check if everything is all right.

# unmount /dev/mapper/vg-disk1
# e2fsck -f /dev/mapper/vg-disk1
# resize2fs -p /dev/mapper/vg-disk1 100G
# lvreduce -L 100G /dev/mapper/vg-disk1

This reduces the size of the partition absolute to 100G. Now you repeat this steps with the other disk, you want to get some space of. If the e2fsck failed, you can extend the partition further up until it works with:

# lvextend +1G /dev/mapper/vg-disk1

Now you can extend the partition and resize the filesystem with:

# umount /dev/mapper/vg-disk0
# lvextend -l +100%FREE /dev/mapper/vg-disk0
# e2fsck -f /dev/mapper/vg-disk0
# resize2fs -p /dev/mapper/vg-disk0
# e2fsck -f /dev/mapper/vg-disk0

This will be it, you can mount the device and use it like before with more space. With the extensive use of e2fsck you can check, if everything worked right.

sources:

How to resize LVM logical volumes with ext4 as filesystem

~ by frankooh on 2012-11-25T14:43:08+01:00.

Leave a comment