RESIZING AN LVM IN A CENTOS VMWARE GUEST

First just check the partition table of the virtual disk in the guest

fdisk -l /dev/sda

 

Disk /dev/sda: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        8354    66999082+  8e  Linux LVM

 

Note : Here showing end cylinders is 8354 but total cylinders 10443 so you have (10443-8354=2089) 2089 remaining cylinders means you can create one more partition with remaining space. When total cylinder equal to end cylinders there is no space left on disk

Now, shutdown the guest in preparation to resize the virtual disk

shutdown

In VMWare Workstation, use vmware-vdiskmanager to resize the VMDK. Note that the disk size given in the “-x” parameter is the desired disk size.

vmware-vdiskmanager.exe -x 80GB “centos-disk-0.vmdk”

Grow: 100% done.

Disk expansion completed successfully.

Boot the CENTOS guest back up, and add a new partition with the free space of the virtual disk. Make sure to use partition id 8e for Linux LVM.

fdisk /dev/sda

n {new partition}

p {primary partition}

3 {partition number}

t {change partition id}

8e {Linux LVM partition}

w

You might need to reboot if fdisk could not update the kernel tables, just do it.

reboot

You can check the parition table after the reboot if you like, make sure it looks like what you expect

fdisk -l /dev/sda

 

Disk /dev/sda: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        8354    66999082+  8e  Linux LVM

/dev/sda3            8355       10443    16779892+  8e  Linux LVM

 

Read the partation table without reboot

#partprobe /dev/sda

 

Now, create a new physical volume from the new partition

#pvcreate /dev/sda3

 

Then extend the existing volume group, you may want to use vgdisplay to list and identify the volume groups you have.

#vgdisplay

— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               148.94 GB
PE Size               32.00 MB
Total PE              4766
Alloc PE / Size       4766 / 148.94 GB
Free  PE / Size       0 / 0
VG UUID               kyUGAZ-STDu-58rJ-vbyy-UHKG-I6SQ-yDHAZA

Here in our case the VG name is VolGroup00. you have to specify VG name following command.

#vgextend VolGroup00 /dev/sda3

 

Now, extend the logical volume, again, use lvdisplay to list and identify the logical volumes you have.

# lvdisplay
— Logical volume —
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                3GuqXY-xK7B-uTil-jl6d-cjfL-QK2t-FcFqq9
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                146.94 GB
Current LE             4702
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:0

— Logical volume —
LV Name                /dev/VolGroup00/LogVol01
VG Name                VolGroup00
LV UUID                BBMNVK-4b9d-OVSI-gKgI-B8Uw-Lgu0-uqa0AN
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                2.00 GB
Current LE             64
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:1

Here we are extending /dev/VolGroup00/LogVol00. following command to extend logical volume.

#lvextend /dev/VolGroup00/LogVol00 /dev/sda3

 

And finally, resize the filesystem in the logical volume

#resize2fs /dev/VolGroup00/LogVol00

 

Done.

Advertisements
Posted in Linux

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: