Xen: How to Convert An Image-Based Guest To An LVM-Based Guest
Xen: How to Convert An Image-Based Guest To An LVM-Based GuestVersion 1.0 This short article explains how you can move/convert a Xen guest that uses disk images to LVM volumes. Virtual machines that use disk images are very slow and heavy on disk IO, therefore it's often better to use LVM. Also, LVM-based guests are easier to back up (using LVM snapshots). I do not issue any guarantee that this will work for you!
1 Preliminary NoteTo use LVM-based guests, you need a volume group that has some free space that is not allocated to any logical volume. In this example, I use the volume group /dev/vg0 with a size of approx. 465GB... vgdisplay server1:~# vgdisplay ... that contains the logical volume /dev/vg0/root with a size of approx. 232GB and the logical volume /dev/vg0/swap_1 (about 1GB) - the rest is not allocated and can be used for Xen guests: lvdisplay server1:~# lvdisplay I have an image-based Xen guest called xen1.example.com that I created using the following command: xen-create-image --hostname=xen1.example.com --size=4Gb --swap=256Mb --ip=192.168.0.101 --memory=128Mb --arch=amd64 --role=udev This is its Xen configuration file: vi /etc/xen/xen1.example.com.cfg
As you see, the guest is using two disk images, /home/xen/domains/xen1.example.com/disk.img (4GB) and /home/xen/domains/xen1.example.com/swap.img (256MB). We need the exact image sizes so that we can create logical volumes of the same size. If you don't remember the exact disk and swap sizes anymore, you can go to the directory where the images are stored... cd /home/xen/domains/xen1.example.com ... and run the following command - it will show the image sizes in human-readable format: ls -lh
2 Converting The Images To LVMBefore we convert the images, we must shut down the guest: xm shutdown xen1.example.com Then we create logical volumes of the same size as the disk images, e.g. as follows: lvcreate -L4G -n xen1_root vg0 This creates the logical volumes /dev/vg0/xen1_root (4GB) and /dev/vg0/xen1_swap (256MB): lvdisplay server1:~# lvdisplay Now we can convert the images as follows: dd if=/home/xen/domains/xen1.example.com/disk.img of=/dev/vg0/xen1_root (This can take a lot of time, depending on how big the images are.) Afterwards, we must open /etc/xen/xen1.example.com.cfg... vi /etc/xen/xen1.example.com.cfg ... and change...
... to ...
You can now start the guest again: xm create /etc/xen/xen1.example.com.cfg If everything goes well, you can delete the disk images: rm -f /home/xen/domains/xen1.example.com/disk.img
3 Links
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning







Recent comments
14 hours 21 min ago
16 hours 22 min ago
19 hours 33 min ago
21 hours 52 min ago
23 hours 2 min ago
1 day 21 min ago
1 day 4 hours ago
1 day 7 hours ago
1 day 8 hours ago
1 day 23 hours ago