So, it’s good enough to serve as a reference for Linux users, who plan to extend LVM disk space in Linux distributions other than Redhat and Debian Linux.
Although it’s not necessary, it’s advised to perform full file system backup before carry out this exercise!
The most risky step is to resize file system that resides in a LVM logical volume. Make sure the right file system resizer tool is used. If you’re using
resize2fsto resize a Reiserfs file system, I guess you’ll know how bad will be the consequences.
Apparently, you’ll need
resize_reiserfsto resize a Reiserfs file system, which is part of the
Steps to extend /home file system that mounts on logical volume /dev/vg0/lvol1 of volume group vg0, by using a new 36GB SCSI hard disk added to RAID 0 of HP Smart Array 5i Controller.
1) Log in as root user and type
init 0to shutdown Redhat Enterprise AS 3 Linux.
2) Add in the new 36GB SCSI hard disk. Since HP Smart Array 5i is configure for RAID 0, it’s fine to mix hard disks of different capacity, except that hard disk speed must be the same! A mix of 10K and 15K RPM hard disks might cause Redhat Enterprise Linux fails to boot up properly.
Normally, HP Smart Array 5i Controller will automatically configure new hard disk as a logical drive for RAID 0. If not, press F8 on boot up to get in HP Smart Array 5i Controller setup screen and manually create logical drive as part of RAID 0.
How to tell if new hard disk is not configured as logical drive for RAID 0?
Physically, the hard disk green light should be on or blinking to indicate that it’s online to RAID system.
From OS level, 3rd hard disk in RAID 0 of HP Smart Array 5i Controller is denoted as /dev/cciss/c0d2. So, type
at root command prompt. If an error message Unable to open /dev/cciss/c0d2 or alike is returned, it means that new hard disk is not online to RAID system or Redhat Linux.
3) Boot up Redhat Enterprise Linux into multi-user mode and confirm it’s working properly. This step is not necessary, but it’s a good practice to prove that the server is working fine after each change has been made, be it a major or minor change.
init 1at root command prompt to boot into single user mode. Whenever possible, boot into single user mode for system maintenance as to avoid inconsistency or corruption.
5) At the root command prompt, type
to create partition for the 3rd SCSI hard disk added to RAID 0. Each hard disk needs at least one partition (maximum 4 primary partitions per hard disk) in order to use the new hard disk in a Linux system.
6) While at the fdisk command prompt, type
mto view fdisk command options.
nto add a new partition, followed by
pto go for primary partition type.
1to create the first partition. Press ENTER to accept first cylinder default as 1, and press ENTER again to accept the default value for last cylinder, which is essentially create single partition that use up all hard disk space.
tto change the partition system id, or partition type. As there is only one partition, partition 1 is automatically selected for action. Type
Lto list all supported partition type. As shown in partition type listing, type
8eto set partition 1 as Linux LVM partition type.
pto confirm partition /dev/cciss/c0d2p1 has been created in partition table. Type
wto write the unsaved partition table of changes to hard disk and exit from fdisk command line.
df -hTato confirm /home file system type, that’s mounts on logical volume /dev/vg0/lvol1. For this case, it’s an ext3 file system type.
umount /hometo un-mount /home file system from Redhat Enterprise Linux.
13) Next, type LVM command
to create a new LVM physical volume on the new partition /dev/cciss/c0d2p1.
14) Now, type another LVM command
vgextend vg0 /dev/cciss/c0d2p1
to extend LVM volume group vg0, with that new LVM physical volume created on partition /dev/cciss/c0d2p1.
pvscanto display physical volumes created in Linux LVM system, which is useful to answer questions such as “How many physical volume created in volume group vg0?”, “How much of free disk space left on each physical volume?”, “How do I know which physical volume should be used for a logical volume?” “Which physical volume has free disk space for used with a logical volume?”, etc.
Sample output of
ACTIVE PV “/dev/cciss/c0d0p4″ of VG “vg0″ [274.27GB / 0 free]
ACTIVE PV “/dev/cciss/c0d1p1″ of VG “vg0″ [33.89GB / 0 free]
ACTIVE PV “/dev/cciss/c0d2p1″ of VG “vg0″ [33.89 GB / 33.89 GB free]
total: 3 [342.05 GB] / in use: 3 [342.05 GB] / in no VG: 0 
vgdisplay vg0 | grep PEto confirm that new physical volume has been added to volume group vg0. Take note of Free PE / Size, 35GB in this case, that’s free disk space added by new physical volume in volume group vg0.
16) Execute LVM command
lvextend -L +33G /dev/vg0/lvol1 /dev/cciss/c0d2p1
to extend the size of logical volume /dev/vg0/lvol1 of volume group vg0 by 33GB on physical volume /dev/cciss/c0d2p1.
17) Now, the most risky steps to start. Type this command
e2fsck -f /dev/vg0/lvol1
to force ext3 file system check on /dev/vg0/lvol1. It’s a must to confirm file system is in good state, before implement any changes on it.
CAUTION – Utility
e2fsckis only used to check EXT file system such as ext2 and ext3, and not other file system such Reiserfs file system!
Once the ext file system check completes without errors or warnings, type command
to resize EXT3 file system of /home, that mounts on logical volume /dev/vg0/lvol1, until it takes up all free disk space added to /dev/vg0/lvol1.
CAUTION – Utility
resize2fsis only used to resize EXT file system such as ext2 and ext3, and not other file systems such as Reiserfs file system!
resize2fsutilities are part of e2fsprogs package. And both utilities takes some minutes to complete, depends on the size of target file system.
If everything alright, type
mount /hometo re-mount /home file system. Next, type
df -hto confirm that /home file system has been extended successfully.