首先来看一下功能
[root@KuaiCDN ~]# qemu-imgqemu-img version 1.5.3, Copyright (c) 2004-2008 Fabrice Bellardusage: qemu-img command [command options]QEMU disk image utilityCommand syntax:check [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filenamecreate [-q] [-f fmt] [-o options] filename [size]commit [-q] [-f fmt] [-t cache] filenamecompare [-f fmt] [-F fmt] [-T src_cache] [-p] [-q] [-s] filename1 filename2convert [-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_filenameinfo [-f fmt] [--output=ofmt] [--backing-chain] filenamemap [-f fmt] [--output=ofmt] filenamesnapshot [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filenamerebase [-q] [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filenameresize [-q] filename [+ | -]sizeamend [-q] [-f fmt] [-t cache] -o options filename
check 检查虚拟磁盘完整性create 创建一个磁盘镜像commit 向后备磁盘提交当前的变化compare 比较两个img占用diskconvert 转换info 信息map 映射snapshot 快照管理resize 调整大小amend 修订镜像格式选项
查看创建 qcow2 格式有哪些选项
qemu-img create -f qcow2 -o ?
[root@KuaiCDN img]# qemu-img create -f qcow2 -o ?Supported options:size Virtual disk sizecompat Compatibility level (0.10 or 1.1)backing_file File name of a base imagebacking_fmt Image format of the base imageencryption Encrypt the imagecluster_size qcow2 cluster sizepreallocation Preallocation mode (allowed values: off, metadata, falloc, full)lazy_refcounts Postpone refcount updates[root@KuaiCDN img]#
创建虚拟磁盘文件
qemu-img create -f qcow2 "$_system_img" 100G -o preallocation=off
查看磁盘信息
[root@KuaiCDN disk]# qemu-img info system.qcow2image: system.qcow2file format: qcow2virtual size: 400G (429496729600 bytes)disk size: 3.0Gcluster_size: 65536Format specific information:compat: 1.1lazy refcounts: false[root@KuaiCDN disk]#
https://blog.csdn.net/qq_40908430/article/details/104197374
https://blog.csdn.net/u012324798/article/details/109705017
