Preparing Xen guest filesystems

Xen guest are using filesystems exported to them via Xen hypervisor Virtual Block Devices (VBDs). Currently there are three methods of preparing such filesystems for Xen.

File-backed VBDs

This is the least-performant Xen VBD type: all disk I/O must pass in hypervisor via loop-mounted filesystem (hence the significant performance drop). However these are the easiest to implement and still suitable for no-I/O-intensive guests.

In order to prepare a file-backed VBD use dd:

   /bin/dd if=/dev/zero of=/somefile_somewhere.img bs=1024M count=20
will prepare 20GB VBD for the guest.

NOTE: Please avoid creating sparse VBDs for use with SLC3/SLC4 guests ( the skip dd option): system installer will get confused about these and most likely crash.

Such prepared VBD should be then exported to guest system in its config file in following way:

disk = [ 'file:/somefile_somewhere.img,sda,w' ]

Physical (Raw) device VBDs

Physical device VBDs will offer much better performance than file-based but are less convenient for the management (these reside on real device / partition).

In order to prepare a physical-device backed VBD use parted:

# /sbin/parted /dev/sda
GNU Parted 1.6.19
...
Using /dev/sda
(parted) p
Disk geometry for /dev/sda: 0.000-152627.835 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031   1027.595  primary   ext3        boot
2       1027.595  21030.402  primary   ext3
3      21030.403  25125.095  primary   linux-swap
(parted) mkpart extended 25125.095 152627.835
(parted) mkpart logical 25125.095 55125.095
(parted) mkpart logical 55121.462 85121.462
(parted) p
Disk geometry for /dev/sda: 0.000-152627.835 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031   1027.595  primary   ext3        boot
2       1027.595  21030.402  primary   ext3
3      21030.403  25125.095  primary   linux-swap
4      25125.095 152625.344  extended
5      25125.126  55121.462  logical
6      55121.493  85117.829  logical
(parted) q

Above illustrates an example parted session where two VBDs were created for use by Xen guests: sda5 (minor 5) and sda6 (minor 6).

NOTE: fdisk can be used to partition your devices too, but with current Xen Domain 0 kernels it will be necessary to reboot the hypervisor as fdisk fails to notify the kernel about partition table changes.

Such prepared VBD should be then exported to guest system in its config file in following way:

disk = [ 'phy:sda5,sda,w' ]

LVM based VBDs

LVM based VBDs offer at the same time good performance and management flexibility: because of LVM device management flexibility

resize existing root file system

Unless you have set aside space for the virtual machines when installing the hypervisor, you'll need to liberate some space that is currently taken up by the hypervisor's root filesystem. In this example, we'll restrict the hypervisor to 10G (original post).

Reboot into rescue mode (sorry, resizing the "/" filesystem cannot be done while it is mounted, so you'll need to boot from floppy/network/USB/..) and run

# lvm vgchange -a y
# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs -f /dev/VolGroup00/LogVol00 10G
# lvm lvreduce -L10G /dev/VolGroup00/LogVol00
This assumes that your physical volume group is called VolGroup00 and the logical volume for "/" is LogVol00 (compare with what the first lines spits out). Which seem to be the default for anaconda-generated LVs.

Create new Volume Group for the guest

Create a Volume Group for the new machine (5GB in this case):
# lvm lvcreate -L5G -ndomU1 VolGroup00
  Logical volume "domU1" created
This can be done both from the rescue system or from the running hypervisor.

Configure Xen to use the new Volume Group

Export the new "device" to the guest via the config file:
...
disk = [ 'phy:VolGroup00/domU1,sda,w' ]

-- JaroslawPolok - 23 Nov 2006
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2006-11-29 - JanIven
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LinuxSupport All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback