首先来看一下功能

  1. [root@KuaiCDN ~]# qemu-img
  2. qemu-img version 1.5.3, Copyright (c) 2004-2008 Fabrice Bellard
  3. usage: qemu-img command [command options]
  4. QEMU disk image utility
  5. Command syntax:
  6. check [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename
  7. create [-q] [-f fmt] [-o options] filename [size]
  8. commit [-q] [-f fmt] [-t cache] filename
  9. compare [-f fmt] [-F fmt] [-T src_cache] [-p] [-q] [-s] filename1 filename2
  10. convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename
  11. info [-f fmt] [--output=ofmt] [--backing-chain] filename
  12. map [-f fmt] [--output=ofmt] filename
  13. snapshot [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename
  14. rebase [-q] [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
  15. resize [-q] filename [+ | -]size
  16. amend [-q] [-f fmt] [-t cache] -o options filename
  1. check 检查虚拟磁盘完整性
  2. create 创建一个磁盘镜像
  3. commit 向后备磁盘提交当前的变化
  4. compare 比较两个img占用disk
  5. convert 转换
  6. info 信息
  7. map 映射
  8. snapshot 快照管理
  9. resize 调整大小
  10. amend 修订镜像格式选项

查看创建 qcow2 格式有哪些选项

  1. qemu-img create -f qcow2 -o ?
  1. [root@KuaiCDN img]# qemu-img create -f qcow2 -o ?
  2. Supported options:
  3. size Virtual disk size
  4. compat Compatibility level (0.10 or 1.1)
  5. backing_file File name of a base image
  6. backing_fmt Image format of the base image
  7. encryption Encrypt the image
  8. cluster_size qcow2 cluster size
  9. preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
  10. lazy_refcounts Postpone refcount updates
  11. [root@KuaiCDN img]#

创建虚拟磁盘文件

  1. qemu-img create -f qcow2 "$_system_img" 100G -o preallocation=off

查看磁盘信息

  1. [root@KuaiCDN disk]# qemu-img info system.qcow2
  2. image: system.qcow2
  3. file format: qcow2
  4. virtual size: 400G (429496729600 bytes)
  5. disk size: 3.0G
  6. cluster_size: 65536
  7. Format specific information:
  8. compat: 1.1
  9. lazy refcounts: false
  10. [root@KuaiCDN disk]#

https://blog.csdn.net/qq_40908430/article/details/104197374
https://blog.csdn.net/u012324798/article/details/109705017