How to extend a logical volume and its filesystem online in Red Hat Enterprise Linux?


问题

  • What is the procedure to grow an existing filesystem based on Logical Volume?

  • How can I extend my logical volume and the filesystem in the command line?

  • I have extended a logical volume using lvextend which shows the extension in volume group vgdisplay but df isn't reflecting the size, Am I missing something?

  • How do I grow an ext3/ext4 filesystem on lvm?

  • How do I increase my filesystem on fly, without unmounting the filesystem ?

  • We are using LVM for mounting the filesystem, how can we use the lvextend to extend the volume group and resize the filesystem?

  • What are the steps to extend a filesystem after a LUN capacity has been extended?

  • What is the procedure to increase the size of an LVM2 logical volume and resize its filesystem?

  • I need to expand a filesystem created on LVM partition, is the filesystem need to be unmounted when expanding it or can I resize it online?

决议

  • The followings are sample steps to extend a volume group, a logical volume, and a filesystem.

NOTE: Red Hat recommends that all critical data be backed up and verified before making any changes to the underlying storage as an unforeseen problem might occur.

1. Create a physical volume from a free disk or partition (e.g. /dev/sdc1 as a partition)

    # pvcreate /dev/sdc1

2. Extend the volume group (/dev/sdc1 is an existing physical volume path).

    # vgextend vgdata /dev/sdc1

3. Extend the logical volume (/dev/vgdata/lvdata is the existing logical volume path), which will be extended in 125 GB.

    # lvextend -L +125G /dev/vgdata/lvdata

4. Extend an ext2/3 filesystem on the logical volume.

    # resize2fs /dev/vgdata/lvdata

If the filesystem is ext4 with Red Hat Enterprise Linux 5, use resize4fs command instead of the resize2fs command.

5. If the filesystem is a GFS extend, see "How do I grow a GFS2 file-system on RHEL5?".

  • For more details, refer the tech brief How to Increase the Size of an LVM2 Logical Volume which walks through an example in which unpartitioned disk space is added to an existing volume group in order to extend a logical volume and the corresponding file system, while they are active.