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.



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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: