#########################
# # # #15. System Virtual Machine Management # # # #
#########################
# # # #1. Installation # # #
#!/bin/bash # #命令运行环境的指定
Virt-install \ # #安装虚拟机
--name \ # #虚拟机名称指定, which represents the first string of characters after the script
--ram \ # #内存
--FILE/VAR/LIB/LIBVIRT/IMAGES/$1.IMG \ # #硬盘文件
--file-size 8 \ # #硬盘文件大小
--cdrom/var/ftp/pub/iso/rhel-server-7.1-x86_64-dvd.iso & # #安装源指定
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9C/FE/wKiom1l4jpezgwixAACSr3wg5m0505.png "title=" Screenshot from 2017-07-26 10-48-19.png "alt=" Wkiom1l4jpezgwixaacsr3wg5m0505.png "/>
# # # #2. Manage # # # # # # #
virt-manager # #开启图形管理工具
Virt-viewer vmname # #显示虚拟机, Vmname represents the virtual machine name
Virsh list # #列出正在运行的vm
Virsh list--all # #列出所有vm
Virsh start vmname # #运行指定vm
Virsh shutdown vmname # #正常关闭指定vm
Virsh destroy vmname # #强行结束指定vm
Virsh Create vmname.xml # #临时恢复指定vm, Vmname represents the front end management file
Virsh define vmname.xml # #永久恢复vm
Virsh undefine vmname # #删除vm的前端管理, storage not deleted
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9C/FE/wKiom1l4jxWzMqcWAACyGru75tA140.png "style=" float : none; "title=" screenshot from 2017-07-26 10-14-10.png "alt=" Wkiom1l4jxwzmqcwaacygru75ta140.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9C/FE/wKioL1l4jxXwBaunAACuXaGTf6g253.png "style=" float : none; "title=" screenshot from 2017-07-26 10-13-40.png "alt=" Wkiol1l4jxxwbaunaacuxagtf6g253.png "/>
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9C/FE/wKiom1l4jxbxFFMZAAHyLRojr8w751.png "style=" float : none; "title=" screenshot from 2017-07-26 10-12-58.png "alt=" Wkiom1l4jxbxffmzaahylrojr8w751.png "/>
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9C/FE/wKioL1l4jxeCnhlOAAHfF9jI7h8353.png "style=" float : none; "title=" screenshot from 2017-07-26 10-12-48.png "alt=" Wkiol1l4jxecnhloaahff9ji7h8353.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9C/FE/wKioL1l4jxfRBkz_AACwv4LeI1A414.png "style=" float : none; "title=" screenshot from 2017-07-26 09-21-59.png "alt=" Wkiol1l4jxfrbkz_aacwv4lei1a414.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9C/FE/wKiom1l4jxiieuvoAADnfCJ8FZA101.png "style=" float : none; "title=" screenshot from 2017-07-26 09-19-06.png "alt=" Wkiom1l4jxiieuvoaadnfcj8fza101.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9C/FE/wKiom1l4jxiibS5FAABEuzFIZdo199.png "style=" float : none; "title=" screenshot from 2017-07-26 09-17-45.png "alt=" Wkiom1l4jxiibs5faabeuzfizdo199.png "/>
# # # #3. Virtual Machine Snapshot # # #
Qemu-img create-f qcow2-b Vm2.qcow2 node1.qcow2
!/bin/bash
Virsh Destroy $ &>/dev/null
Virsh undefine $ &>/dev/null
Qemu-img create-f qcow2-b/var/lib/libvirt/images/$1.qcow2/var/lib/libvirt/images/$2.qcow2 &>/dev/null
Virt-install \
--name
--ram 1000 \
--DISK/VAR/LIB/LIBVIRT/IMAGES/$2.QCOW2 \
--import &>/dev/null &
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9C/FE/wKioL1l4j3ThbBFeAAUpseQWvz0686.png "style=" float : none; "title=" screenshot from 2017-07-26 12-00-00.png "alt=" Wkiol1l4j3thbbfeaaupseqwvz0686.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9C/FE/wKiom1l4j3XxOBZ8AAENN9EFgmI133.png "style=" float : none; "title=" screenshot from 2017-07-26 11-40-00.png "alt=" Wkiom1l4j3xxobz8aaenn9efgmi133.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9C/FE/wKioL1l4j3axsa9zAAEy7JVW4Dg811.png "style=" float : none; "title=" screenshot from 2017-07-26 11-19-18.png "alt=" Wkiol1l4j3axsa9zaaey7jvw4dg811.png "/>
This article is from the "13122425" blog, please be sure to keep this source http://13132425.blog.51cto.com/13122425/1951234
Linux Cloud Automation Basics 15 (Basic operation of virtual machines)