Creating LVM Volume Group

By Zhiqiang Ma On Feb 25, 2013

How to create a LVM group from two hard disk partitions is introduced in this post.

Assume we have installed two hard disks /dev/sdb and /dev/sdc to the server, our task now is to create one LVM volume group vg_xen for installing LVM backed Xen DomUs from these two disks. We will do this by several steps: create partitions on the hard disks, initialize disk partitions and create a volume group.

Create partitions on the hard disks

We can use fdisk to create partitions:
# fdisk /dev/sdb
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/sdb1
Follow the same procedure to create partition /dev/sdc1

Initialize disk partitions

Create volume group descriptors at the starts of partitions:

# pvcreate /dev/sdb1
# pvcreate /dev/sdc1

Create a volume group

We create LVM volume group vgxen that contains /dev/sdb1 and /dev/sdc1:

# vgcreate vg
xen /dev/sdb1 /dev/sdc1

Activate the new added volume group

We can activeate it by scan the volume groups:
# vgscan

Add new physical volumes to the volume group

If we installed another hard disk /dev/sdd afterwards, we can create partition /dev/sdd1 on it and initialize it as introduced above. Then we can add the new physical volume to the volume group:
# vgextend vg_xen /dev/sdd1
A more detailed tutorial of extending a LVM volume group can be found here: Extending a LVM Volume Group.

By: Zhiqiang Ma Last updated: Feb 25, 2013 Views: 2,867
Tags: , ,

About Zhiqiang Ma

Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed system, etc. Find Zhiqiang on Facebook, Twitter, LinkedIn and Google+.

5 Comments on Creating LVM Volume Group | Add Comment
Add your comments, share your thoughts

Be nice. Keep it clean. Stay on topic. No spam.