KVM Raw and QCOW2 format Virtual disk creation

Source: Internet
Author: User


Before creating a virtual machine, first add a virtual machine disk, use image in KVM to represent the virtual disk, and before adding the virtual machine disk
First you need to know how to make an image

QEMU-IMG is a Disk management tool for QEMU

One, image creation in RAW format
1. Create an image in raw format with a capacity of 20g
Qemu-img create-f Raw Ubuntu14.04.raw 20G

2. View image Information
[Email protected]:/datapool/image# qemu-img Info Ubuntu14.04.raw
Image:ubuntu14.04.raw
File Format:raw
Virtual size:20g (21474836480 bytes)
Disk size:0


Second, create an image in the Qcow2 format
1. Create an image of 20g qcow2 format
Qemu-img create-f qcow2-o Cluster_size=2m,backing_file=ubuntu14.04.raw ubuntu-nova.qcow2 40G

Third, the relevant note:
1. Using a derived image we have just created a ubuntu14.04.raw image, such as a system installed using this mirrored virtual machine.
Then we can use this system by creating a derived image to avoid a system for every virtual machine created
Case

2, here use Backing_file way to create qcow2 format image, where the 40G does not really occupy 40G, but limited the
The maximum size of the Ubuntu-nova.qcow2 file.

3. When the system installed in the RAW format file is a Windows series, create the QCOW2 format last
The file size needs to be 2-3 times larger than the raw format, such as creating a Win7.raw format file of size 30G, creating the QCOW2 Format Disk command as follows:
Qemu-img create-f qcow2-o Cluster_size=2m,backing_file=win7.raw windows-7.qcow2 60G

4. The Ubuntu-nova.qcow2 file here is not a standalone image and needs to be used with the Ubuntu14.04.raw disk when used
Need to keep backing_file absolute path unchanged, Qcow2 file can be moved. The virtual machine is directly interacting with the QCOW2 format image, raw format image as Backing_file
is completely transparent to the virtual machine. In fact, the Qcow2 file is the write-time copy policy, the QCOW2 format image just saves all the change data, the raw format of the image
There is no change in the data.

5, read operation: If the virtual machine does not change the data, then the virtual opportunity directly read the RAW format disk, otherwise read the data on the QCOW2 disk

6. Write operation: If the data on the raw virtual disk is not the same as when writing, save this part of the data to the QCOW2 format disk

7, performance, QCOW2 format disk compared with the direct use of raw format disk, read and write performance slightly decreased, but the loss is not obvious, the disk IO requirements of the lower virtual machine recommended the use of RAW format virtual machine disk

8. What are the benefits of doing so? 1th: The RAW format will occupy a lot of space after creation, such as the creation of a 20G rawge format image, then it will occupy 20G, then the QCOW2 format image is dynamic growth

9, Qcow2 is a more mainstream of the current virtual disk format, with small footprint, support encryption, support compression, support snapshot features

Qcow2 format image can also not use Backing_file (at this point: the QCOW2 format and the raw format of the only but not qcow2 is dynamic growth, the other basic is not too big difference)
Qemu-img create-f qcow2 Ubuntu14.04.qcow2 20G

This article is from the "Fa&it-Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1877841

KVM Raw and QCOW2 format Virtual disk creation

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.