Extend LVM Partition in Linux

Posted on 7:45 PM by Bharathvn

Say that you are running out of space and you want to add more space to your LVM volume.

To do that, unmount the volume and use the lvresize command. After that, you
must also check the file system with e2fsck and run resize2fs to resize the ext3
file system on that volume:

$ sudo umount /mnt/u1 Unmount volume
$ sudo lvresize --size 16M /dev/vgusb/lvm_u1 Resize volume

Extending logical volume lvm_u1 to 16.00 MB
Logical volume lvm_u1 successfully resized

$ sudo e2fsck -f /dev/vgusb/lvm_u1
e2fsck 1.40 (12-Jul-2007)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vgusb/lvm_u1: 12/3072 files (25.0% non-contiguous), 3379/12288 blocks
$ sudo resize2fs /dev/vgusb/lvm_u1 16M Resize file system
resize2fs 1.38 (30-Jun-2005)

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

In the example just shown, the volume and the file system are both resized to 16MB.
Next, mount the volume again and check the disk space and the md5sum you created
earlier:

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

Filesystem 1M-blocks Used Available Use% Mounted on /dev/mapper/vgusb-lvm_u1
16 4 13 20% /mnt/u1

$ md5sum /mnt/u1/vmlinuz-2.6.20-1.2316.fc5 Recheck md5sum
8d0dc0347d36ebd3f6f2b49047e1f525 /mnt/u1/vmlinuz-2.6.20-1.2316.fc5

The newly mounted volume is now 16MB instead of 10MB in size.