KVM Virtualization Technology (VI) Disk Management

Source: Internet
Author: User

Types of virtual disks supported by KVM

Raw

This is not a real disk format, but represents the original image used by the virtual machine; it does not store metadata, so it can be a candidate for virtual machine compatibility, but also because

It does not store metadata, so some advanced features, such as snapshots and compression, cannot be supported.

Simple format, easy to convert to other formats; requires file system support to support sparse file

Cow copy-on-write format, ephemeral

Qcow qemu Early copy-on-write format, bridging scheme

Qcow2

Allocate disk space on demand, regardless of file system support

Supports snapshot, compression, encryption

How do I copy data from a virtual machine when there is a problem? Without booting the case, how to hang the hard disk file?

First we find the disk file location of the virtual machine, where the storage pool is located, take/var/lib/libvit/image/as an example

1 #cd/var/lib/libvirt/images/2[[email protected] images]#qemu-img Info Rhel6.6.qcow23image:rhel6.6. Qcow24 file Format:qcow25Virtual size:9.0g (9663676416bytes)6Disk Size:1. 7G7cluster_size:655368 Format Specific information:9compat:1.1TenLazy Refcounts:true

Conversion of the format:
Qemu-img convert-f Qcow2-o Raw Rhel7.qcow2 rhel7.img
QEMU-IMG convert-f source Format-o destination format source disk destination disk

RAW Format Disk Mount:
Kpartx-av rhel7.img------will map rhel7.img to several files after execution
LOOP0P1 (boot) loop0p2 rhel-root (/) Rhel-swap (swap) under/dev/mapper/
You can copy the data by mounting it separately
kpartx-d rhel7.img-----Delete swap-back mappings

Qcow2 Format Disk Mount
The NBD module must be added to the kernel.
Idea: Qcow2 first converted to RAW format, in RAW format to operate

1. View existing disk image formats and conversions
(1) View disk format
# qemu-ing Info kvmname.img
Raw format needs to be converted into Qcow2
(2) Turn off the virtual machine and convert the disk
#virsh shutdown Kvmname
(3) Convert disk format
# qemu-img convert-f raw-o qcow2 kvmname1.img kvmname2.qcow2
-F Source Image format
-O Destination Mirroring format
After viewing the conversion format, it has been converted to Qcow2, where a copy is made, and the format is converted into Qcow2
# qemu-img Info Kvmname2.qcow2

Qemu-img create-f Qcow2/data/test1.qcow2 10G
1. Add a disk to the virtual machine online
(1) View existing disks
# Virsh Domblklist Kvmname
(2) Create a qcow2 virtual disk
# qemu-img create-f qcow2 test_add.qcow2 5G
(3) Adding virtual disks
# Virsh Attach-disk Kvmname/path/test_add.qcow2 VDB
Added at this point will disappear after a reboot, you need to save the newly added disk configuration to the configuration file
# Virsh Dumpxml Kvmname
<disk type= ' file ' device= ' disk ' >
<driver name= ' qemu ' type= ' qcow2 ' cache= ' None '/>
<source file= '/data/test02_add01.qcow2 '/>
<target dev= ' vdb ' bus= ' Virtio '/>
<alias name= ' Virtio-disk1 '/>
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x06 ' function= ' 0x0 '/>
</disk>
# Virsh Edit Kvmname


Modify the configuration file (/etc/libvirt/qemu/) of a virtual machine to define a new virtual machine based on the replicated send disk

KVM Virtualization Technology (VI) Disk Management

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.