Advertisements

Resizing an ext3 filesystem mounted on a logical volume in a Linux

My home directory got full

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
101M 96M 94K 100% /home

Checking if the logical volume permits online resizing and if it was created with an older e2fsprogs version. Volumes created prior to SUSE Linux 10 SP2 are using an older e2fsprogs version and needs to be recreated

root@linux:~ # dumpe2fs -h /dev/mapper/rootvg-homevol | grep features
dumpe2fs 1.35 (28-Feb-2004)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file

We checked that the volume has the resize_inode property so to extend the filesystem, first we extend the logical volume

root@linux:~ # lvextend -L 200M /dev/rootvg/homevol
Extending logical volume homevol to 200.00 MB
Logical volume homevol successfully resized

You can see that the filesystem is not yet showing the new size

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
101M 96M 95K 100% /home

Now we increase the filesystem with resize2fs

root@linux:~ # resize2fs /dev/rootvg/homevol
resize2fs 1.41.9 (22-Aug-2009)
Filesystem at /dev/rootvg/homevol is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/rootvg/homevol to 204800 (1k) blocks.
The filesystem on /dev/rootvg/homevol is now 204800 blocks long.

Checking the new size

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
194M 94M 90M 52% /home

If you receive a message saying that you can’t resize a mounted filesystem, use ext2online

root@suselinux10:~ # resize2fs /dev/localVG/sys.opt
resize2fs 1.38 (30-Jun-2005)
/dev/localVG/sys.opt is mounted; can’t resize a mounted filesystem!

root@suselinux10:~ # ext2online /dev/localVG/sys.opt
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b

You can also pass the flag -r to resize the filesystem without using resize2fs and use lvresize instead of lvextend

root@linux:~ # lvresize -L +2g -r /dev/vgHQ0ascs/lv_sapmnt_exe
Size of logical volume vgHQ0ascs/lv_sapmnt_exe changed from 5.00 GiB (1280 extents) to 7.00 GiB (1792 extents).
Logical volume lv_sapmnt_exe successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vgHQ0ascs-lv_sapmnt_exe is mounted on /export/sapmnt/HQ0/exe; on-line resizing required
old desc_blocks = 20, new_desc_blocks = 28
Performing an on-line resize of /dev/mapper/vgHQ0ascs-lv_sapmnt_exe to 7340032 (1k) blocks.
The filesystem on /dev/mapper/vgHQ0ascs-lv_sapmnt_exe is now 7340032 blocks long.

Advertisements
%d bloggers like this: