1.选择一个你要用来制作的虚拟机(举例为ecs8888)
2.在此虚拟机里安装你想要安装的软件/驱动
3.不同操作系统下初始化虚拟机
(1)在“C:\Windows\System32\”目录下新建一个start.bat,内容为:
call C:\change.bat
call del C:\change.bat
(2)运行中输入gpedit.msc打开本地策略组编辑器
(3)打开Windows设置→脚本→双击启动
(4)添加C:\Windows\System32\start.bat
(5)正常关闭系统或者在面板上使用软关机
(6)执行拷贝命令把系统镜像拷贝为模版
cp /home/nokvm/resource/ecs8888/uuid_sys.qcow2 /home/nokvm/templates/模版名称.qcow2
(1)安装在线修改密码服务并设置为开机启动
yum install qemu-guest-agent
systemctl start qemu-guest-agent
systemctl enable qemu-guest-agent
(2)编辑/etc/rc.d/rc.local在文件中添加以下内容:
sh /root/change.sh && rm -rf /root/change.sh
(3)之后执行chmod +x /etc/rc.d/rc.local
(4)正常关闭系统
(5)执行拷贝命令把系统镜像拷贝为模版
cp /home/nokvm/resource/ecs8888/uuid_sys.qcow2 /home/nokvm/templates/模版名称.qcow2
(1)安装在线修改密码服务并设置为开机启动
yum install qemu-guest-agent
chkconfig --add qemu-ga
(2)编辑/etc/rc.d/rc.local在文件中添加以下内容:
sh /root/change.sh && rm -rf /root/change.sh
(3)之后执行chmod +x /etc/rc.d/rc.local
(4)正常关闭系统
(5)执行拷贝命令把系统镜像拷贝为模版
cp /home/nokvm/resource/ecs8888/uuid_sys.qcow2 /home/nokvm/templates/模版名称.qcow2
(1)安装在线修改密码服务
sudo apt-get install qemu-guest-agent
(2)编辑/etc/rc.local 文件在exit 0之前添加以下内容:
/etc/init.d/qemu-guest-agent start
sh /root/change_other.sh && rm -rf /root/change_other.sh
(3)之后执行chmod +x /etc/rc.local
(4)正常关闭系统
(5)执行拷贝命令把系统镜像拷贝为模版
cp /home/nokvm/resource/ecs8888/uuid_sys.qcow2 /home/nokvm/templates/模版名称.qcow2
1.下载windows下virtio驱动ISO文件(linux不用下载)并添加到光盘媒介
https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html
2.以下是ISO中包含文件的内容
3.新建或选择一台现有虚拟机加载需要系统的ISO镜像
4.如何扩大或缩小系统盘?
关闭系统后执行以下命令:
qemu-img resize 镜像文件 +10G #扩大10G容量
qemu-img resize 镜像文件 -10G #缩小10G容量
5.然后进入正常windows/linux正常安装流程
linux可以正常安装。windows则需要加载virtio-win的驱动。
在光驱挂载页面先取消windows系统的挂载,然后挂载virtio-win-XXX.iso加载硬盘驱动。
加载驱动完成后取消驱动ISO挂载,重新挂载windows系统ISO然后继续按照安装流程安装。
![]()
6.安装完毕后进入系统后执行以下操作
(1)在“C:\Windows\System32\”目录下新建一个start.bat,内容为:
call C:\change.bat call del C:\change.bat
(2)运行中输入gpedit.msc打开本地策略组编辑器
(3)打开Windows设置→脚本→双击启动
(4)添加C:\Windows\System32\start.bat
7.加载virtio-win-的驱动ISO,安装如下程序
guest-agent/ - QEMU Guest Agent 32位和64位MSI安装程序
8.优化安装你自己的软件
9.安装驱动请继续从virtio-win-的驱动ISO中安装
10.正常关机/主控面板中软关机
11.执行拷贝命令把系统镜像拷贝为模版
cp /home/nokvm/resource/ecs8888/uuid_sys.qcow2 /home/nokvm/templates/模版名称.qcow2
[scode type="green" size="small"]镜像命名方式 以下开头命名镜像名称:
centos
windows
debian
ubuntu[/scode]
windows模版
wget -O /home/nokvm/templates/windows7.qcow2 http://45.253.64.15:8013/templates/vip/win/windows7.qcow2
wget -O /home/nokvm/templates/windows10_x64_zh.qcow2 http://45.253.64.15:8013/templates/vip/win/windows10_x64_zh.qcow2
wget -O /home/nokvm/templates/windows10_x64_en.qcow2 http://45.253.64.15:8013/templates/vip/win/windows10_x64_en.qcow2
wget -O /home/nokvm/templates/windows2003r2.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2003r2.qcow2
wget -O /home/nokvm/templates/windows2003r2_x86.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2003r2_x86.qcow2
wget -O /home/nokvm/templates/windows2003R2_10G.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2003R2_10G.qcow2
wget -O /home/nokvm/templates/windows2008r2.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2008r2.qcow2
wget -O /home/nokvm/templates/windows2012r2.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2012r2.qcow2
wget -O /home/nokvm/templates/windows2012r2_standard.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2012r2_standard.qcow2
wget -O /home/nokvm/templates/windows2016.qcow2 http://45.253.64.15:8013/templates/vip/win/windows2016.qcow2
wget -O /home/nokvm/templates/windows10_x64_zh.qcow2 http://45.253.64.15:8013/templates/vip/win/windows10_x64_zh.qcow2
linux模版:
wget -O /home/nokvm/templates/centos6.5.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos6.5.qcow2
wget -O /home/nokvm/templates/centos6.8.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos6.8.qcow2
wget -O /home/nokvm/templates/centos7.0.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos7.0.qcow2
wget -O /home/nokvm/templates/centos7.2.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos7.2.qcow2
wget -O /home/nokvm/templates/centos7.4.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos7.4.qcow2
wget -O /home/nokvm/templates/centos7.5.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos7.5.qcow2
wget -O /home/nokvm/templates/centos7.6.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos7.6.qcow2
wget -O /home/nokvm/templates/centos8.1.qcow2 http://45.253.64.15:8013/templates/vip/linux/centos8.1.qcow2
wget -O /home/nokvm/templates/ubuntu16.4.qcow2 http://45.253.64.15:8013/templates/vip/linux/ubuntu16.4.qcow2
wget -O /home/nokvm/templates/ubuntu18.4.qcow2 http://45.253.64.15:8013/templates/vip/linux/ubuntu18.4.qcow2
wget -O /home/nokvm/templates/ubuntu19.10.qcow2 http://45.253.64.15:8013/templates/vip/linux/ubuntu19.10.qcow2
wget -O /home/nokvm/templates/debian10.3.qcow2 http://45.253.64.15:8013/templates/vip/linux/debian10.3.qcow2
]]>