Wednesday, April 17, 2013

Expand LVM in CentOS 6

# review your disk layout
fdisk -l

# scan for new disk.
echo "- - -" > /sys/class/scsi_host/host0/scan

# check disk layout again {notice changes}
fdisk -l

fdisk /dev/sda
p  (print partition table)
n  (New partition)
p  (primary partition)
3  (ID #3 (this may be different for you, since I already had /dev/sda1 and 2)

# When asked for block value, add 1 to the end of block value for sda2 partition and use it as the start of the sda3 partition.  

t  (change partition type)
3 (change partition 3)
8e (Type = Linux LVM)
p (print the partition table again)
w (write the partition table)

# Now create a new LVM physical volume from the partition you just created.
lvm pvcreate /dev/sda3
lvm pvdisplay

# Mount the volume group
lvm vgscan
lvm vgchange -ay
* a message will echo that the volume group is activated.

# extend the volume group with the new physical volume.  change the volume group hostname with yours. 
lvm vgextend /dev/vg_vdevd01 /dev/sda3

# now extend the logical volume to include the new partition. 
lvm lvextend /dev/vg_vdevd01/lv_home /dev/sda3

# Mount the volume group
lvm vgscan
lvm vgchange -ay

# Run a filesystem check on the newly expanded disk
e2fsck -f /dv/vg_hostname/lv_root

# resize the filesystem to use the entire disk
resize2fs /dev/vg_vdevd01/lv_home

# reboot and check your new disk 
df -h

No comments:

Post a Comment