Storage

Xen guests can use several types of storage. This page covers the most common options.

File-backed disk images

The simplest storage option is a raw disk image file stored in dom0’s filesystem.

Create an image:

dd if=/dev/zero of=/var/lib/xen/images/myguest.img bs=1M count=20480

This creates a 20 GB sparse file. Use it in a guest configuration with:

disk = [ "file:/var/lib/xen/images/myguest.img,xvda,w" ]

File images are easy to manage and move, but have some performance overhead compared to block devices.

Physical block devices and LVM

For better performance, give guests direct access to a physical block device or a logical volume (LVM).

Create an LVM logical volume:

lvcreate -L 20G -n myguest vg0

Use it in a guest configuration:

disk = [ "phy:/dev/vg0/myguest,xvda,w" ]

The phy: prefix tells Xen to use the block device directly. This avoids the filesystem overhead of file images.

Disk configuration format

The general format for a disk entry is:

"source,target,access"
source

The storage source: phy:/dev/... for a block device, file:/path/to/... for a file image.

target

The device name seen by the guest: xvda for a paravirtualized disk, hda for an emulated IDE disk (HVM only).

access

w for read-write, r for read-only.

Multiple disks can be listed:

disk = [ "phy:/dev/vg0/root,xvda,w",
         "phy:/dev/vg0/data,xvdb,w",
         "file:/path/to/installer.iso,xvdc:cdrom,r" ]