大网数据广告活动
服务器运维问答

qemu/kvm file/block disk device types - and iothreads

· 52CE 我爱测

On a CentOS 7 host, I'm creating a VM from an Amazon Linux 2 qcow2 image: Download Amazon Linux 2 cloud-init image (.qcow2 format) Copy this file, run qemu-img resize to expand it to 40G Define it in my VM using <disk type='file'…

问题原文

原帖链接 · turbonerd · CC BY-SA 4.0

On a CentOS 7 host, I'm creating a VM from an Amazon Linux 2 qcow2 image:

  • Download Amazon Linux 2 cloud-init image (.qcow2 format)
  • Copy this file, run qemu-img resize to expand it to 40G
  • Define it in my VM using <disk type='file'> and <source file='my_resized_file.qcow2'>

This works - but I'm running ~30 VMs on this host, all running quite heavy Docker workloads - and the disk IO isn't good enough.

I want to try using iothreads, cache=none and io=native as a number of posts online indicate improved performance for SSDs and high-CPU count hosts with these settings. I have plenty of CPU to spare.

I've tried simply adding iothreads=1 to the domain and iothread=1 to the disk, but this fails with the error IOThreads not supported for this QEMU. I presume this is because I'm using disk type=file rather than disk type=block.

I would like to:

  • Use the OS image, and its cloud-init functions
  • Have 40G available to the VM
  • Use raw file type, iothreads, cache=none and io=native for maximum performance

My question is therefore...

How do I get my qcow2 OS image to become a 40G raw block device that I can use with these parameters?

已采纳解答

原帖链接 · mforsetti · CC BY-SA 4.0

To convert from QCOW2 to RAW image file, use qemu-img convert, for example:

$ qemu-img convert -O raw /path/to/image.qcow2 /path/to/image.bin

IOThreads is supported on QEMU since QEMU 2.0. QEMU 2.0.0 is available on EPEL, so try to run:

# yum -y install epel-release
# yum makecache && yum -y install qemu

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。