[CentOS] Slightly OT: First Time KVM and LVM on Centos

Thu Jun 16 00:06:11 UTC 2011
Gordon Messmer <yinyang at eburg.com>

On 06/13/2011 02:00 PM, Jeff Boyce wrote:
> I am a novice system administrator and will soon be purchasing a new server
> to replacing an aging file server for my company.  I am considering setting
> up the new server as a KVM host with two guests; one guest as the Samba file
> server and a second guest as a testing area.  My old server was set up about
> 7 years ago and has a 5 disk raid 5 configuration without LVM.

My first piece of advice would be to avoid RAID5.  The performance is 
terrible.

> I understand
> the benefits of using LVM and KVM in the right circumstances, but have never
> used either of them.  I have spent a couple of days over the last week
> trying to understand how to setup a KVM host with guests, but there is an
> area that I still don't understand; that is the relationship between the
> underlying raid partitions, LVM, and allocating space to a host and guests.

That should be pretty simple...  During the installation of the host 
system, you'll partition your drives as you need them.  I try to keep 
mine simple, for example:
http://home.dragonsdawn.net/kickstart/centos5

That configuration will put two partitions on each of two drives.  Each 
drive gets a small partition which will be arranged in a RAID1 set; that 
RAID1 set is mounted at /boot.  The other partition, which fills the 
rest of each disk, form another RAID1 set.  That RAID1 set is an LVM 
physical volume.  That PV forms a volume group named VolGroup.  All of 
the host's filesystems and its swap are created on logical volumes 
inside that volume group.

So on my "simple" setup, I have four partitions on two drives.  Two 
partitions are used for /boot, and the other two are used for the 
physical volume.  All filesystems other than /boot are on logical volumes.

In that kickstart file, /var will fill all of the available space.  On a 
KVM host, you'd want to set a fixed size for /var instead.  That would 
leave you with some of your volume group unallocated when the 
installation is complete.

When you set up your guests, you can start by allocating a new logical 
volume from your volume group.  That LV will get a device file in 
/dev/mapper.  When you set up your guest, you use that LV as the guest's 
disk.  The guest will treat that LV as if it were a disk drive.  The 
guess will create partitions on it (and possibly LVM of its own) and 
filesystems on top of those partitions or logical volumes just as if it 
were a physical machine with a disk drive.

> Many of the standard search term combinations in Google don't seem to be
> getting me anywhere.  From what I have read so far I think that I want to
> have my file server guest using a raw partition rather than an image file,
> but I haven't found anything with examples or best-practices guidance for
> partitioning or volume management with hosts and guest VMs.  So I am hoping
> that someone here can give me some pointers, or point me to some clear
> how-to's somewhere.  Any help is appreciated.  Thanks.

That's probably true.  image file backed guests are a whole lot slower 
than guests that run on partitions or logical volumes.  Logical volumes 
are the easiest option to manage, with good performance characteristics.

Hopefully that made sense.  Ask questions if not.