Resized my root filesystem online

Wanted to increase the size of my root filesystem. I have my CentOS 5.3 in an LVM

[tony@localhost ~]$ df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/CentOsVG-RootLV
16G   11G  3.8G  75% /

Decided to use a less used NTFS partition. (i have a Linux/Windows multiboot system)

The steps i did,
1. Created a new Physical volume using the spare partition

[tony@localhost ~]$ su -
Password:
[root@localhost ~]# pvcreate /dev/sda8
Physical volume "/dev/sda8" successfully created

Use pvdisplay to see the newly created physical volume, if required.

2. Extended the Volume Group to include this physical volume.

[root@localhost ~]# vgextend CentOsVG /dev/sda8
Volume group "CentOsVG" successfully extended

3. Now, Enlarge the size of the Logical volume and then the filesystem.
I knew i have to use lvextend command, but got confused after reading the man pages, so finally decided to use the Graphical Utiliy. :-D
System > Administration > Logical Volume Management
Clicked on my volume group and then, the required logical volume and ‘Edit Properties‘.
Set the size to use the ‘Use Remaining‘ and Ok
The system prompted for enlarging file system size, and it was all over!

Later i figured out that i should have used the command,
lvextend /dev/CentOsVG/CentOsVG-RootLV /dev/sda8
or
lvextend /dev/CentOsVG/CentOsVG-RootLV/ -l +100%FREE

And perhaps increase the size of root filesystem by using resize2fs

Shouldn’t this require an umount of the /? And so use a ‘rescue environment’ or live CD?
No! Online increase of ext3 partitions are available from kernel 2.6.10

Finally checked the size of the root

[tony@localhost ~]$ df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/CentOsVG-RootLV
25G   11G   13G  47% /

Leave a Reply

Your email address will not be published. Required fields are marked *


3 + nine =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>