Home > Linux, Redhat, Uncategorized > How to add extend a vg and extend your logical volume online RHEL 5

How to add extend a vg and extend your logical volume online RHEL 5

Using LVM is the best option for flexibility in maintenance on filesystems.

In this example, I already have vg01 created. Now, I will allocate a new LUN from the SAN storage. After it is presented to the host, you can dynamically scan for the new device. (Reference: https://willsnotes.wordpress.com/2011/01/29/dynamically-scan-your-luns-for-new-hosts-without-reboot/ )

Run fdisk to see the new disk:
# fdisk -l

Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 5 40131 de Dell Utility
Partition 1 does not end on cylinder boundary.
/dev/sda2 * 6 267 2097152 b W95 FAT32
Partition 2 does not end on cylinder boundary.
/dev/sda3 268 279 96390 83 Linux
/dev/sda4 280 17769 140488425 5 Extended
/dev/sda5 280 17769 140488393+ 8e Linux LVM

Disk /dev/sdc: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn’t contain a valid partition table

Disk /dev/sde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn’t contain a valid partition table

In this case, sde is the new device. Now, initialize the physical volume for LVM usage:
# pvcreate /dev/sde
Writing physical volume data to disk “/dev/sde”
Physical volume “/dev/sde” successfully created

Next, extend vg01 volume group with the new physical volume:
# vgextend vg01 /dev/sde
Volume group “vg01” successfully extended

Now, take a look at vginfo to see more “Free PE” physical extents available.
# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group “vg01”

— Volume group —
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 599.94 GB
PE Size 32.00 MB
Total PE 19198
Alloc PE / Size 9599 / 299.97 GB
Free PE / Size 9599 / 299.97 GB
VG UUID KfcbNP-oT11-elBN-dqv5-g4et-0HMA-TfHK1F

— Logical volume —
LV Name /dev/vg01/lvol1
VG Name vg01
LV UUID G0Tb24-E8Le-gZfu-1vRV-SlOy-SIJF-nt0vJv
LV Write Access read/write
LV Status available
# open 1
LV Size 299.97 GB
Current LE 9599
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2

— Physical volumes —
PV Name /dev/sdc
PV UUID 8fNwun-9cvK-aNC0-HKrO-cBt7-O0It-46X7Lx
PV Status allocatable
Total PE / Free PE 9599 / 0

PV Name /dev/sde
PV UUID K6cbAV-XrV8-MtX7-oS0b-hkMM-3Dvc-x1jFcG
PV Status allocatable
Total PE / Free PE 9599 / 9599

Next, extend the logical volume.
# lvextend -l +100%FREE /dev/vg01/lvol1
Extending logical volume lvol1 to 599.94 GB
Logical volume lvol1 successfully resized

Finally, resize the filesystem online.
# resize2fs /dev/vg01/lvol1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg01/lvol1 is mounted on /oradata; on-line resizing required
Performing an on-line resize of /dev/vg01/lvol1 to 157270016 (4k) blocks.
The filesystem on /dev/vg01/lvol1 is now 157270016 blocks long.

Run “df” and you should see your mount point increase by the extended size.

Categories: Linux, Redhat, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: