Shrinking an LVM Volume

Posted on 11:10 PM by Bharathvn

You can also use the lvresize command if you want to take unneeded space from an existing
LVM volume. As before, unmount the volume before resizing it and run e2fsck (to check the file system) and resize2fs (to resize it to the smaller size):

$ sudo umount /mnt/u1
$ sudo e2fsck -f /dev/vgusb/lvm_u1
fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)

The filesystem size (according to the superblock) is 16384 blocks

The physical size of the device is 8192 blocks
Pass 1: Checking inodes, blocks, and sizes

/dev/vgusb/lvm_u1: 12/3072 files (8.3% non-continguous,3531/16384 blocks
$ sudo resize2fs /dev/vgusb/lvm_u1 12M Resize file system
resize2fs 1.38 (30-Jun-2005)

Resizing the filesystem on /dev/vgusb/lvm_u1 to 12288 (1k) blocks.
The filesystem on /dev/vgusb/lvm_u1 is now 12288 blocks long.

$ sudo lvresize --size 12M /dev/vgusb/lvm_u1

\WARNING: Reducing active logical volume to 12.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvm_u1? [y/n]: y
Reducing logical volume lvm_u1 to 8.00 MB

Logical volume lvm_u1 successfully resized

$ sudo mount -t ext3 /dev/mapper/vgusb-lvm_u1 /mnt/u1 Remount volume
$ df -m /mnt/u1 See 4MB of 12MB used

Filesystem 1M-blocks Used Available Use% Mounted on
12 4 9 20% /mnt/u1

The newly mounted volume appears now as 12MB instead of 16MB in size.