System Administration
Showing results for 
Search instead for 
Did you mean: 

increase and decrease file system sizes on red hat linux

Go to solution
Waqar Razi
Regular Advisor

increase and decrease file system sizes on red hat linux

I am an hpux administrator and we have the first linux server in our environment. I have a question, how to increase or decrease the file system size on linux provided that we are using lvm and ext3 file system.
Honored Contributor

Re: increase and decrease file system sizes on red hat linux

The first step (lvextend) should be very familiar from the HP-UX side. However, Linux offers a few convenient shortcuts:

- you can use letters k, M, G, T to identify the desired size. For example, to extend a LV to 100 gigabytes:

lvextend -L 100G /dev/vgSomething/lvolX

- or you can specify the amount to increase with a + sign. For example, to add 10 gigabytes:

lvextend -L +10G /dev/vgOther/lvolY

After the lvextend step is complete, the next step depends on your Linux distribution and version. For RedHat Enterprise Linux 4, the command is "ext2online /mountpoint".
(Don't worry about the "ext2": because ext3 = ext2 + journaling, the same filesystem tools apply for both ext2 and ext3.)

If the filesystem is created using an older version of Linux, it might not support online extension. In this case, unmount it and use "resize2fs /dev/vgSomething/lvolX".

To add the possibility for online extension, you can use "ext2prepare /dev/vgSomething/lvolX". This re-arranges the disk data so that the metadata areas can grow if necessary: the modern mke2fs command does this automatically when a filesystem is created, but the older versions did not.

For RedHat Enterprise Linux 5 (and probably other current Linux distributions), the functionality of ext2online is added to resize2fs. This one command can do both online & offline resizing as necessary.

To shrink a filesystem, the filesystem must be unmounted. First run resize2fs with a size argument (see "man resize2fs"). Then lvreduce the LV to match the new size. Beware: if you reduce the LV more than you reduced the filesystem, you will damage your data.