https://developer.aliyun.com/article/799104

还可以看看这个

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
yum -y install libguestfs-tools

要设置root密码,请使用以下命令:
virt-customize -a CentOS-7-x86_64-GenericCloud.qcow2 --root-password password:123456

[   0.0] Examining the guest ...

[   1.9] Setting a random seed

[   1.9] Setting passwords

[   6.8] Finishing off

注:

CentOS-7-x86_64-GenericCloud.qcow2是要修改图像的名称。

123456是为root用户设置的密码。