Increase LVM Volume

I had the occasion to need some extra filespace on the LVM’d root partition of a RHEL(or CentOS) vm. This is how to do it:

First off, VMWare allowed me to create a second HDD on the fly while the vm was running (YAY!)

Once that was done, I rooted into the server and:

# echo “- – -” > /sys/class/scsi_host/host#/scan
(partprobe should also do the trick ??)

# fdisk -l
(Just to see that the new disk is available – in this case /dev/sdb)

# fdisk /dev/sdb
(create a new partition here)

# mkfs.ext3 /dev/sdb1

# vgs
(list the volume groups here)

# pvcreate /dev/sdb1
(add new physical volume)

# vgextend VolGroup00 /dev/sdb1
(extend my default volume group from the vgs command)

# vgs
(check to see pv and vg has another volume now)

# lvextend /dev/VolGroup00/LogVol00 /dev/sdb1
(extend my / volume by the entire size of /dev/sdb1)

# resize2fs /dev/VolGroup00/LogVol00
(resize filesystem to match vol size increase)
(requires a 2.6 kernel to resize while fs running)

That was it! And remember that all this was done on the fly, on the root partition and filesystem, WHILE the vm was running.

One Comment

Leave a Reply

You must be logged in to post a comment.