Setting Up LVM Backed Xen DomU
Posted on In Linux, VirtualizationLVM 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]].
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
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 ;-)
This one is correct:
disk=[‘phy:fedora_VG/vm1,xvda,w’]
Show us result of ‘lvs’ if it does not work.
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.
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.
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.
What’s the command to start the VM with the .cfg file? Is the previous VM shutted down?
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.
How did you solve it and what was the problem?
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=
Thanks for the update.
I see. You built the Xen software from the source code instead of the packages from Fedora’s repository.
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.
If the VM runs just well, I usually do not worry about that message.
“If a Linux VM is running in full PV mode then it won’t have any PCI available so that message would be perfectly normal as the kernel tries to initialize all systems.” — http://discussions.citrix.com/topic/328311-pci-fatal-no-config-space-access-function-found-centos-63-x64/
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 .
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.
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.