Xen VM uses LVM snapshot Image

Source: Internet
Author: User

Generally, virtual machine image files are directly stored in an IMG image file or directly partitioned using/dev/SDA. However, if the Virtual Machine partition is "broken", it will be hard to recover.

Qemu supports qcow2, an image format that allows you to create Incremental Images. This allows you to store modifications in new files and protect the original image when an error occurs. This function is very useful,[Xen seems to support qcow2, to be checked]But xen itself does not.

Xen only supports incremental images.Use the snapshot function of the LVM file system. (Note: Because the xen hvm uses qemu as the frontend, The qcow2 format can also be used. However, PV virtual machines can only use LVM snapshot)

LVM can create multiple snapshots for a partition as the incremental image of the partition. The modification in the snapshot does not affect the source partition.

When creating a snapshot, you must specify the snapshot size.When the snapshot space is filled up, LVM will discard the snapshot (strange settings ),So try not to fill it up ...... The new LVM version allows you to merge snapshot and ontology partitions. If you want to modify the ontology and snapshot at the same time after creating a snapshot, you can use this Merge function.

The specific configuration is as follows.

Environment:

The LVM version is 2.02.54. This version is relatively old.The new version supports merging snapshot and ontology partitions.

Gui uses KDE kvpm and system-config-LVM in GNOME

The LVM file system can be defined on physical partitions or image files. I am using the/dev/SDA * partition.

Create an LVM partition:

Sudo pvcreate/dev/sda11-V

Note that this step will erase the partition header information. The remaining steps for allocating volume groups/partitions can be completed in the GUI. The final result is as follows:
/Dev/sda11 (physicalVolume)
--- Vg0 (group0)
------ PV (10 Gb, ext4)
------ Swap (512 MB, swap)

Others reserved for hvm virtual machines and snapshot

After installing and configuring all the content in the image PV, use the GUICreate two Snapshot: Pv-shot1 and pv-shot2, both 2 GB

ThenModify the virtual machine configuration file:

 
Xm_vars.var ('Volume ', use = "specify the logical volume (snapshot) used") disk = ["phy:/dev/vg0/% s, xvda2, W "% volume,] Name = 'debian-Pv-% s' % volume

Command Line during running:

 
Sudo XM create-C debian-pv.cfg volume = pv-shot1

In this way, all modifications to the started virtual machine are carried out in snapshot, and the original image can be well protected.

 
 

 
 
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.