Skip to content

Instantly share code, notes, and snippets.

@thikade
Created February 14, 2017 10:27
Show Gist options
  • Save thikade/020a189817b17d74eea1e9b14cb8b0b7 to your computer and use it in GitHub Desktop.
Save thikade/020a189817b17d74eea1e9b14cb8b0b7 to your computer and use it in GitHub Desktop.
reduce ext4 lvm filesystem
# Unmount the filesystem and check its' LV
umount /mnt/foo
e2fsck -f /dev/mapper/vg0-foo
 
# Shrink ext4 and then the LV to the desired size
resize2fs -p /dev/mapper/vg0-foo 40G
lvreduce -L 40G /dev/mapper/vg0-foo
 
# Before continuing, run e2fsck. If it bails because the partition
# is too small, don't panic! The LV can still be extended with
# lvextend until e2fsck succeeds, e.g.: 
# lvextend -L +1G /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
 
# Resize the filesystem to match the LVs size, check and mount it
resize2fs -p /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
mount /mnt/foo

Source & credits: https://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment