Setting Up LVM for Xen or KVM

Why Use LVM?
------------

Cloudmin supports storing Xen and KVM disk images in LVM logical volumes, instead of regular files. This has the speed advantage of avoiding the overhead of going through the filesystem layer on the host system, and can also make adding disk space for virtual systems easier. However, the downside is increased management complexity, as disk images in LVs cannot be easily managed with Linux tools like mv and scp.

Host System Requirements
----------------------

For a Xen or KVM host system to use LVM, it must either have been installed with its filesystems on LVM already, or have free disks that can be used to create an LVM volume group. If a volume group already exists, it must have some free space for new logical volumes.

For increased reliability, we recommend running LVM on top of RAID. For example, a system with 4 disks could have them combined into a Linux software RAID 5 group, which is then used as the underlying physical volume for an LVM volume group. If this ever fills up, 4 more disks could be installed as another RAID 5 set and then added to the volume group as other physical volume.

For Cloudmin to make use of LVM on a host system, it must have Webmin installed. The simplest way to do this is to select the host from the left menu, then go to *System Operations* -> *Install Webmin*. Once Webmin is installed on the host, you can use its LVM and RAID modules under the *Hardware* category to setup volume group.

In the simplest case where you have two extra empty disks and want to add them to a new volume group, you could do the following in Webmin on the host system :

1. Go to *Hardware* -> *Partitions on Local Disks*, and click on the first new disk.
1. If any partitions exist already, delete then. Then create a new primary partition that spans the whole disk with the *Type* menu set to *Linux LVM*.
1. Do the same for the second and any other disks.
1. Go to *Hardware* -> *Logical Volume Management*.
1. If a volume group already exists, click the *Physical volumes* tab, then click *Add a physical volume* and add the disk you setup above. Then do the same for any other disks.
1. If no volume groups exist yet, click the *Add a new volume group* link. Enter a name like "xenvg" and select the first of your new disks, then click *Create*. Once the creation is done, add any other disk to the volume group.

Host System Configuration
---------------------

Once a volume group has been created, you can configure Cloudmin to use it as follows :

1. Login to the Cloudmin master system, and go to *Host Systems* -> *Xen Host Systems* (or *KVM Host Systems*) , and click on the host you just setup LVM on.
1. From the *LVM volume group for disk images* menu, select the new volume group, then click *Save*.
1. Create a test Xen or KVM system on this host, and make sure it works properly. Once it is done, go to *Resources* -> *Manage Disks*, and you should see the first virtual disk stored in a logical volume.