kvm:convert_qcow2_to_raw
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
kvm:convert_qcow2_to_raw [2019/11/30 12:57] – removed peter | kvm:convert_qcow2_to_raw [2020/07/21 16:50] (current) – old revision restored (2016/07/04 10:58) 91.121.7.147 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== KVM - Convert qcow2 to raw ====== | ||
+ | Convert qcow2 disk images to raw disk images for performance. | ||
+ | |||
+ | The **qcow2** disk format has some decent features like encryption, compression and copy to write support. | ||
+ | |||
+ | ===== Benchmark ===== | ||
+ | |||
+ | For me it has a performance boost. Using a RAID 1 setup with two 5900 RPM disks and the **deadline** on the host and the **noop** scheduler without caching on a raw image in the guest resulted in a boost over the default **deadline** scheduler on a qcow2 image on the guest: | ||
+ | |||
+ | Test command: | ||
+ | |||
+ | <code bash> | ||
+ | dd if=/ | ||
+ | </ | ||
+ | |||
+ | Default Ubuntu 12.04 vmbuilder created vm on a qcow2 image without caching and with the deadline scheduler in the VM: | ||
+ | |||
+ | < | ||
+ | 1073741824 bytes (1.1 GB) copied, 658.396 s, 1.6 MB/s | ||
+ | </ | ||
+ | |||
+ | The same VM, disk image converted to raw image without caching and using the noop scheduler in the VM: | ||
+ | |||
+ | < | ||
+ | 1073741824 bytes (1.1 GB) copied, 13.646 s, 78.7 MB/s | ||
+ | </ | ||
+ | |||
+ | That's quite a performance boost. | ||
+ | |||
+ | < | ||
+ | 1073741824 bytes (1.1 GB) copied, 10.4034 s, 103 MB/s | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Converting the image ===== | ||
+ | |||
+ | I'll convert the disk image for the example vm **vm1**. | ||
+ | |||
+ | First shut down the VM: | ||
+ | |||
+ | <code bash> | ||
+ | virsh shutdown vm1 | ||
+ | </ | ||
+ | |||
+ | Then convert all the disk images using this command for each disk image: | ||
+ | |||
+ | <code bash> | ||
+ | qemu-img convert / | ||
+ | </ | ||
+ | |||
+ | Edit the VM config: | ||
+ | |||
+ | <code bash> | ||
+ | virsh edit vm1 | ||
+ | </ | ||
+ | |||
+ | Change the **disk** section to point to the new raw image: | ||
+ | |||
+ | Change the lines **< | ||
+ | |||
+ | <code bash> | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | </ | ||
+ | |||
+ | That's it. Start the VM: | ||
+ | |||
+ | <code bash> | ||
+ | virsh start vm1 | ||
+ | </ | ||
+ | |||
+ | If it all works, remove the qcow2 image: | ||
+ | |||
+ | <code bash> | ||
+ | rm / | ||
+ | </ | ||
+ | |||
+ | ===== Disk scheduler ===== | ||
+ | |||
+ | To change the default disk scheduler in your VM, you can use the following command: | ||
+ | |||
+ | <code bash> | ||
+ | echo $scheduler > / | ||
+ | </ | ||
+ | |||
+ | To check the current scheduler: | ||
+ | |||
+ | <code bash> | ||
+ | cat / | ||
+ | </ | ||
+ | |||
+ | Output: | ||
+ | |||
+ | < | ||
+ | noop [deadline] cfq | ||
+ | </ | ||
+ | |||
+ | Here the **deadline** scheduler is being used. To change it: | ||
+ | |||
+ | <code bash> | ||
+ | echo noop > / | ||
+ | </ | ||
+ | |||
+ | Now the **noop** scheduler is being used: | ||
+ | |||
+ | <code bash> | ||
+ | cat / | ||
+ | [noop] deadline cfq | ||
+ | </ | ||
+ | |||
+ | Remember to add this command to / |
kvm/convert_qcow2_to_raw.1575118655.txt.gz · Last modified: 2020/07/15 09:30 (external edit)