Creating LVM Volume Group

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 vg_xen 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.

About Eric Zhiqiang Ma

Eric 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 systems and etc. Also find Eric on Facebook, Twitter, LinkedIn and Google+. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties. More Posts - Website

0 thoughts on “Creating LVM Volume Group”

  1. Dear Zhiqiang Ma,

    I have small doubt, I have created Volume group(vg) and mount the vg(volume group) in /mnt and stored the some file.

    It is possible to move the Vg partition to another server, Please let me know ?

    Thanks for advance.

    BY

    Mike

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Click to subscribe to Fclose.com Posts by Email if you have not.