This is a step-by-step guide used to extend logical volume group disk space, that’s configured under LVM version 1.x of Redhat Enterprise Linux AS 3. Although, this guide has also been used to extend LVM disk space with a new SCSI hard disk, that’s configured with LVM version 2.x in Debian Sarge 3.1.
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 usingresize2fs
to resize a Reiserfs file system, I guess you’ll know how bad will be the consequences.
Apparently, you’ll needresize_reiserfs
to resize a Reiserfs file system, which is part of thereiserfsprogs
package.
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 0
to 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, typefdisk /dev/cciss/c0d2
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.
4) Type
init 1
at 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
fdisk /dev/cciss/c0d2
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
m
to view fdisk command options.7) Type
n
to add a new partition, followed by p
to go for primary partition type.8) Type
1
to 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.9) Type
t
to change the partition system id, or partition type. As there is only one partition, partition 1 is automatically selected for action. Type L
to list all supported partition type. As shown in partition type listing, type 8e
to set partition 1 as Linux LVM partition type.10) Type
p
to confirm partition /dev/cciss/c0d2p1 has been created in partition table. Type w
to write the unsaved partition table of changes to hard disk and exit from fdisk command line.11) Type
df -hTa
to confirm /home file system type, that’s mounts on logical volume /dev/vg0/lvol1. For this case, it’s an ext3 file system type.12) Type
umount /home
to un-mount /home file system from Redhat Enterprise Linux.13) Next, type LVM command
pvcreate /dev/cciss/c0d2p1
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.
15) Type
pvscan
to 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
pvscan
command: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 [0]
Alternative, type
vgdisplay vg0 | grep PE
to 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
e2fsck
is 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
resize2fs /dev/vg0/lvol1
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
resize2fs
is only used to resize EXT file system such as ext2 and ext3, and not other file systems such as Reiserfs file system!
Bothe2fsck
andresize2fs
utilities 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 /home
to re-mount /home file system. Next, type df -h
to confirm that /home file system has been extended successfully.
No comments:
Post a Comment