Creating LVM Volume Group
Posted on In LinuxHow 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.
Table of Contents
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.
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
Yes, you can.
This tutorials ( http://www.fclose.com/b/linux/2611/duplicating-and-backing-up-lvm-backed-xen-domu-from-a-remote-server/ ) actually includes the duplicating of a LVM partition/volume from a remote server to the local server. You can check it and ignore the parts that are related to Xen VMs.
Oh.. Thanks for your reply.