Setting Up LVM Backed Xen DomU

Posted on In Linux, Virtualization

LVM volumes as backing for DomU’s file system is an appealing solution to Xen VBD. LVM volumes can dynamically grow/shrink and snapshot. These features make it simple and fast to duplicate DomU and adding storage to DomU. Creating LVM-backed Xen DomU is introduced in this post.

Create LVM-backed VBD

Suppose we have a LVM volume group for Xen now:

vg_xen. Let’s create a logical volume of size 20GB named ‘vm-10.0.0.123’ for the VM we will create:

# lvcreate -L20480 -n 'vm-10.0.0.123' vg_xen

Please refer to

[[creating-lvm-volume-group]] for setting up LVM volume group.

The profile for LVM-backed DomU

Then we can create a profile for LVM-bakced Xen DomU using the LVM logical volume we create above:

name="lvm-backed-domainu"
vcpus=2
memory=2048
disk=['phy:mapper/vg_xen-vm--10.0.0.123,xvda,w']
# disk=['phy:vg_xen/vm-10.0.0.123,xvda,w']
vif=['bridge=eth0']
bootloader="/usr/bin/pygrub"
on_reboot='restart'
on_crash='restart'

or for installing a new DomU:

name="F12INSTALL"
vcpus=2
memory=2048
disk=['phy:mapper/vg_xen-vm--10.0.0.123,xvda,w']
# disk=['phy:vg_xen/vm-10.0.0.123,xvda,w']
vif = [ 'bridge=eth0' ]
kernel = "/lhome/xen/f12install/vmlinuz"
ramdisk = "/lhome/xen/f12install/initrd.img"
on_reboot = 'restart'
on_crash = 'restart'

The virtual machine’s name is “10.0.0.123”, memory is 2G, CPU number is 2, VBD is LV /dev/mapper/vg_xen/vm-10.0.0.123. The “disk” line specifies that we will use logical volume

vm-10.0.0.123 in volume group vg_xen for this DomU’s VBD. Then we can install operating system in the DomU. Please refer to the “Install Fedora 12 Linux via Internet” section in: [[setting-up-stable-xen-domu-with-fedora-unmodified-fedora-12-on-top-of-xenified-fedora-12-dom0-with-xen-4-0-0]] for installing Fedora 12 in Xen DomU.

For more tutorials about Xen, please refer to [[xen-solutions]].

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

16 comments

  1. Hi, Eric,

    My Volume Group is fedora_VG, and my logical volumn is vm1, I wite :

    disk=[‘phy:mapper/fedora_VG–vm1,xvda,w’]
    there is error as follow:

    libxl__device_disk_set_backend: Disk vdev=xvda failed to stat:mapper/fedoraVG–vm1:no such file or directory.

    how can I solve this problem ?

    Thank you

  2. disk=[‘phy:fedora_VG/vm1,xvda,w’]
    or
    disk=[‘phy:mapper/fedora_VG–vm1,xvda,w’]
    or
    disk=[‘/dev/mapper/fedora_VG-vm1,xvda,w’]
    or
    disk=[‘/dev/mapper/fedora_VG/vm1,xvda,w’]

    they are all error.

    How to solve this?
    Thank you ;-)

  3. NO. this one does not work
    disk=[‘phy:fedora_VG/vm1,xvda,w’]
    but if I modify it to :

    disk=[‘phy:fedora_VG/vm1, raw, xvda,w’]
    the config file is OK.

    but after that the install need a URL, I type this URL:
    http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Fedora/x86_64/os/

    the installation exit here.

    My lvs looks like this:

    LV VG ATTR LSize
    root fedora_VG -wi-ao 97G
    swap fedora_VG -wi-ao 3G
    vm1 fedora_VG -wi-a 20G

    I don’t know why attr of vm1 is only -wi-a, there is no ‘o’ here.

    1. But in the other comments, you show the one without phy: . Both are good?

      Which version of Linux and xen is the Dom0? The config file seems changed a lot. F12 is too old. You may consider a newer release if there is no specific reason to use F12.

  4. Hi, Eric,

    When I install Domain U, my config file is lvmdomu1.cfg, like this:

    name = ‘lvmdomU1’
    kernel = “/home/shhpeng/Xen-dev/vmlinuz”
    ramdisk = “/home/shhpeng/Xen-dev/initrd.img”
    disk = [‘/dev/mapper/fedora_VG-vm1, raw, xvda, rw’]
    extra = “root=/dev/xvda1”
    vif = [‘bridge=xenbr0’]
    memory = 512
    vcpus = 1
    maxvcpus = 1

    it works,

    But when I copy the config file to another file lvmdomu1.run, and modify it like this:

    name = ‘lvmdomU1-run’

    disk = [‘/dev/mapper/fedora_VG-vm1, raw, xvda, rw’]
    extra = “root=/dev/xvda1″
    bootloader=”pygrub”
    vif = [‘bridge=xenbr0’]
    memory = 512
    vcpus = 1
    maxvcpus = 1

    then

    xl create -f lvmdomu1.run -c

    there is error :
    Traceback (most recent call last):
    File “/usr/local/lib/xen/bin/pygrub”, line 20 , in
    import xen.lowlevel.xc
    ImportError: No module named xen.lowlevel.xc

    How can I solve this problem?
    Thank you.

  5. Hi, Eric,

    the file ” lvmdomu1.run” is the configuration file when I want to boot the domain U.

    The domain U has already been installed.

    Thank you.

  6. The problem is python:

    ImportError: No module named xen.lowlevel.xc

    I solve this by :
    #make dist PYTHON_PREFIX_ARG=
    #make install PYTHON_PREFIX_ARG=

  7. Hi, Eric
    There is another problem.

    When I boot VM, the following message will display :

    PCI : Fatal : No config space access function found.

    What is this ?

    Thank you.

  8. if I login in the VM using root and I cannot modify file “/boot/grub/grub.cfg”.

    it is read only.

    How can I modify this file ?

    Thank you .

    1. It is either the Dom0 or the DomU that makes your /boot/ read-only and there are many possible reasons.

      Without knowing details of your Dom0 and DomU, the others can’t figured out what’s wrong.

  9. Hi, Eric,

    I cann’t use the Internet on domU. How can I copy a file from dom0 to LVM Backed Xen DomU ?

    Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *