Expand Linux Filesystem

If you need to expand or add space to a filesystem under Linux, please follow the procedure outlined below, replacing the directory and filesystem names with your own:

Verify the current filesystem usage and device path:

df -h /u2/eclipse

Verify that the volume group for sufficient space:

vgs datavg

Set the new logical volume size:

lvextend -L 80G /dev/datavg/eclipse

Resize the filesystem:

resize2fs /dev/datavg/eclipse

Verify the updated filesystem utilization:

df -h /u2/eclipse

Here’s an example:

[root@eclipse ~]# df -h /u2/eclipse
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/datavg-eclipse
                       20G   18G  835M  96% /u2/eclipse
[root@eclipse ~]# vgs datavg
  VG     #PV #LV #SN Attr   VSize   VFree
  datavg   1   5   0 wz--n- 474.22G 406.22G
[root@eclipse ~]# lvextend -L 40G /dev/datavg/eclipse
  Extending logical volume eclipse to 40.00 GB
  Logical volume eclipse successfully resized
[root@eclipse ~]# resize2fs /dev/datavg/eclipse
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/datavg/eclipse is mounted on /u2/eclipse; on-line resizing required
Performing an on-line resize of /dev/datavg/eclipse to 10485760 (4k) blocks.
The filesystem on /dev/datavg/eclipse is now 10485760 blocks long.

[root@eclipse ~]# df -h /u2/eclipse
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/datavg-eclipse
                       39G   18G   20G  48% /u2/eclipse

If the LVM snapshot filesystems are mounted, please follow the procedure outlined below.

First, unmount the snap filesystems (and any “child” filesystems, such as /u2/eclipse/ereports under /u2/eclipse):

umount /snap/20110909.1043/u2/eclipse/

Remove the snap logical volumes (which you can identify with the “lvs” command):

lvremove /dev/datavg/lvol1

Set the new logical volume size:

lvextend -L 250G /dev/datavg/eclipse

Resize the filesystem:

resize2fs /dev/datavg/eclipse

If you are unable to unmount or lvremove a snapshot, verify that there are no processes holding the volume open.