首先来看一下功能
[root@KuaiCDN ~]# qemu-img
qemu-img version 1.5.3, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
QEMU disk image utility
Command syntax:
check [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename
create [-q] [-f fmt] [-o options] filename [size]
commit [-q] [-f fmt] [-t cache] filename
compare [-f fmt] [-F fmt] [-T src_cache] [-p] [-q] [-s] filename1 filename2
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
info [-f fmt] [--output=ofmt] [--backing-chain] filename
map [-f fmt] [--output=ofmt] filename
snapshot [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename
rebase [-q] [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
resize [-q] filename [+ | -]size
amend [-q] [-f fmt] [-t cache] -o options filename
check 检查虚拟磁盘完整性
create 创建一个磁盘镜像
commit 向后备磁盘提交当前的变化
compare 比较两个img占用disk
convert 转换
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 size
compat Compatibility level (0.10 or 1.1)
backing_file File name of a base image
backing_fmt Image format of the base image
encryption Encrypt the image
cluster_size qcow2 cluster size
preallocation 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.qcow2
image: system.qcow2
file format: qcow2
virtual size: 400G (429496729600 bytes)
disk size: 3.0G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
[root@KuaiCDN disk]#
https://blog.csdn.net/qq_40908430/article/details/104197374
https://blog.csdn.net/u012324798/article/details/109705017