Xen supports a variety of storage methods, roughly three categories: the most common and direct file storage (Files storage), the local physical hard disk or the LVM storage (physical DEVICES/LVM storage), the more advanced NFS, NAS, GNBD, SAN, AoE, ISCSI network storage (network storage) and so on. These three types of storage media and methods are used in our production environment, each has its own advantages, vpsee bias mixed use, help us understand the characteristics of different technologies.
Scan the system first to see how the LVM is distributed on the system:
# Vgscan
Reading All physical volumes. This could take a while ...
Found Volume Group "vpseexen" using metadata type LVM2
# lvscan
ACTIVE '/dev/vpseexen/root ' [6.52 GB] Inherit
active '/dev/vpseexen/swap_1 ' [9.25 GB] inherit
active '/dev/vpseexen/home ' [116.88 GB] Inherit
Suppose that the virtual machine image we are converting is xen01.img (the corresponding swap partition file is Xen01.swap). First we need to create a logical volume on the volume group to replicate virtual machine mirroring (XEN01.IMG), logical volume size and xen01.img, and a logical volume to replicate the swap file (Xen01.swap):
# lvcreate-l10g-n Xen01_root vpseexen
# lvcreate-l512m-n Xen01_swap vpseexen
After the success of the creation, 2 new logical volumes appear:
# Lvscan
Active '/dev/vpseexen/root ' [6.52 GB] inherit
active '/dev/vpseexen/swap_1 ' [9.25 GB] Inherit
active ' /dev/vpseexen/home ' [116.88 GB] inherit
active '/dev/vpseexen/xen01_root ' [10.00 GB ] Inherit
ACTIVE '/dev/vpseexen/xen01_swap ' [MB] inherit
The virtual machine's mirrored content is then DD onto the logical volume:
# dd if=/home/vpsee/xen/xen01.img of=/dev/vpseexen/xen01_root
# dd If=/home/vpsee/xen/xen01.swap of=/dev/ Vpseexen/xen01_swap
To modify the Xen profile of the virtual machine, guest and host start with the same Xen kernel:
# vi/etc/xen/xen01
kernel = "/boot/vmlinuz-2.6.26-2-xen-amd64"
RAMDisk = "/boot/ Initrd.img-2.6.26-2-xen-amd64 "
Vcpus = 1
memory = 256
name =" Xen01 "
vif = [']
disk = [
' Phy:/dev/vpseexen/xen01_root,sda1,w ',
' phy:/dev/vpseexen/xen01_swap,sda2,w ']
root = "/DEV/SDA1"
Extra = "FastBoot"
The final boot copy of the successful LVM based virtual machine is OK:
# XM Create Xen01
Management reference for LVM:
Physical Volume Volume Group Logical Volume
Scan Pvscan Vgscan Lvscan
Create Pvcreate vgcreate lvcreate
Display Pvdispaly Vgdisplay Lvdisplay
Remove Pvremove vgremove lvremove
1. Create LVM,
1.1 Create and initialize an LVM-enabled partition
# PVCREATE/DEV/SDA10
1.2 Create a VG (volume group) on this partition and name ' VG '
# vgcreate VG/DEV/SDA10
1.3 Create a logical partition on this VG LV (logical volume), size 4GB, and named ' Myvmdisk1 '
# lvcreate-l4096m-n Myvmdisk1 VG
1.4 Now you should be able to get this:/dev/vg/myvmdisk1, create a file system on it, install it, copy it into the system, and then install it back:
# mkfs-t Ext3/dev/vg/myvmdisk1
# mount/dev/vg/myvmdisk1/mnt
# Cp-ax//mnt
# umount/mnt
1.5 modifying Xen configuration files to be like this
disk = [' Phy:vg/myvmdisk1,sda1,w ']
Note that you must reverse install the partition before you start Xen. Otherwise, it cannot be started.
In a SUSE10 environment, this process can also be achieved through a graphical interface, with LVM and XEN icons in the Yast/system.