Extending a LVM Volume Group
Posted on In Linux, SoftwareWe introduced how to create a LVM group with two hard disk partitions, which the LVM group can be used for [[setting-up-lvm-backed-xen-domu|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.
Table of Contents
Create a partition on the new hard disk
We can use fdisk to create a new partition:
# fdisk /dev/sdd
Add 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:
/dev/sdd1
Initialize the disk partition
Create 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 group
Now we can add the new physical volume to the volume group:
# vgextend vg_xen /dev/sdd1
The vg_xen LVM group’s capacity is extended. We can display the information of the volume group by
# vgdisplay
and the information of the logical volumes by
# lvdisplay
and the information of the physical volumes by
# pvdisplay