Increasing size of an EXT3 formatted LVM Volume (BASH)

This details the steps required to unmount and resize an ext3 formatted logical volume (LVM) on Linux. The steps listed are performed on Debian, but should be more or less the same for any distro.

The basic approach is more or less the same for any filesystem, though some of the tools used for resizing may vary

Details

  • Language: BASH

Snippet

# Set the following variables
#
# MOUNTPOINT - should be the path of the mount (e.g. /mnt/myfiles)
# VOL_NODE - The node of the LVM volume, will normally be /dev/[VOLGROUP NAME]/[Volume Name]
#

# Get details of the node used by the mount
mount | grep $MOUNTPOINT

# If exported via NFS, Remove it from NFS exports to unlock the mount point
nano /etc/exports 
service nfs-kernel-server restart

# Unmount the volume
umount $MOUNTPOINT

# Check how much unallocated space is in the Volume Group 
vgdisplay 

# Extend the mount by 1TB 
lvextend -L+1T $VOL_NODE

# Run a FSCK against the filesystem (otherwise resize2 will refuse to run)
e2fsck -f $VOL_NODE

# Resize the filesystem to the new size of the volume
resize2fs $VOL_NODE

# Mount again
mount $MOUNTPOINT

# Verify the new size
df -h | grep $MOUNTPOINT

# If needed, re-enable in NFS
nano /etc/exports
service nfs-kernel-server restart