Extending a LVM Volume Group
We introduced how to create a LVM group with two hard disk partitions, which the LVM group can be used for installing LVM backed Xen DomUs. The LVM volume can have large capacity from several hard disks. However, we may use all the disk space after some time and we may need to extend the capacity. In this post, we introduce how to extend a LVM group with a new hard disk.
Assume we have created one LVM volume group vg_xen and we have plugged a new disk sdd to the server. Now we will extend the volume group with the new hard disk sdd.
Create a partition on the new hard diskWe can use fdisk to create a new partition:
# fdisk /dev/sddAdd a new partition by command: n
Select primary partition by: p
Select partition number 1: 1
Then select from the first section to the last one.
Write table to disk and exit by command: w
We can find out the new partition in /dev/ directory:
$ ls /dev/sd*We can find:
Initialize the disk partitionCreate a volume group descriptor at the starts of the partition and create a new physical volume:
# pvcreate /dev/sdd1
Add the new physical volume to the volume groupNow we can add the new physical volume to the volume group:
# vgextend vg_xen /dev/sdd1The vg_xen LVM group’s capacity is extended. We can display the information of the volume group by
# vgdisplayand the information of the logical volumes by
# lvdisplayand the information of the physical volumes by