You have a logical volume (LV) on a Linux server that is running out of space and need to extend it. The volume is formatted EXT4.
All the commands below require you have root privileges to work as expected so you will need to login directly as root, login as a normal user and su, or login as a normal user with sufficient sudo privileges.
- Run /sbin/vgdisplay and check the “Free PE / Size” field to verify that there is enough space on the volume group (VG) to expand the logical volume. If not, you’ll need to either add disks or remove space from other LVs on the same VG.
- Use /sbin/lvdisplay and check the “LV Size” field to verify the current size of the volume.
- Use /sbin/lvextend with the -L switch to specify the new size of the LV. For example, to extend logical volume “lv_home” on volume group “vg_0” to be 1TB in size:
# lvextend -L1TB /dev/vg_0/lv_home
NOTE: lvextend will let you make the LV smaller; make sure the size specified is the correct size.
- If you run /bin/df, the disk will still show it’s original size. Even though the logical volume is bigger, you still need to make the file system aware of the new space. You can do this using the /sbin/resize2fs command:
# resize2fs /dev/vg_0/lv_home
By default, resize2fs will extend the file system to use all available space on the LV so there’s no need to provide a target size. This process may take several minutes so you may want to run it either from the local console or inside a screen session to avoid any potential for a dropped SSH session killing the resize.