1 下载镜像
# 资源地址:https://cloud.centos.org/centos/7/images/
wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2c
2 拷贝虚拟机镜像
cp CentOS-7-x86_64-GenericCloud-2009.qcow2c vm1-CentOS-7-x86_64-GenericCloud-2009.qcow2c
cp CentOS-7-x86_64-GenericCloud-2009.qcow2c vm2-CentOS-7-x86_64-GenericCloud-2009.qcow2c
cp CentOS-7-x86_64-GenericCloud-2009.qcow2c vm3-CentOS-7-x86_64-GenericCloud-2009.qcow2c
3 修改root密码
# 安装libguestfs-tools
sudo apt install libguestfs-tools -y
# 修改
sudo /usr/bin/virt-customize -a vm1-CentOS-7-x86_64-GenericCloud-2009.qcow2c --root-password password:123456
sudo /usr/bin/virt-customize -a vm2-CentOS-7-x86_64-GenericCloud-2009.qcow2c --root-password password:123456
sudo /usr/bin/virt-customize -a vm3-CentOS-7-x86_64-GenericCloud-2009.qcow2c --root-password password:123456
4 启动虚拟机
#!/bin/bash
image='/home/dewan/vm/images/vm1-CentOS-7-x86_64-GenericCloud-2009.qcow2c'
name='vm1-centos7'
cmd=(
virt-install
--name $name
--os-type=linux
--os-variant=rhel7.0
--ram=2048
--vcpus=2
--cpu host-model
--disk path=${image},bus=virtio
--network bridge=virbr0,model=virtio,link_state=up
--force
--import
# --autostart
)
"${cmd[@]}"
标签:qcow2c,x86,Centos,--,虚拟机,CentOS,GenericCloud,64,Image
From: https://www.cnblogs.com/dewan/p/17268315.html