######## #虚拟机的安装 ######
With super users
1.
2. Scripts
Non-interactive
[Email protected] ~]# virt-install \
>--name linux \
>--file/var/lib/libvirt/images/linux.qcow2 \
>--file-size 8 \
>--ram 800 \
>--cdrom/home/kiosk/desktop/rhel-server-7.2-x86_64-dvd.iso &
Script:
[Email protected] mnt]# vim vm_create
#!/bin/bash # # #命令运行环境的指定
virt-install \ # # #安装虚拟机
--name linux \ # # #虚拟机名称的指定
--file/var/lib/libvirt/images/linux.qcow2 \ # # #硬盘文件
--file-size 8 \ # # #硬盘文件大小
--ram # # #内存
--cdrom/home/kiosk/desktop/rhel-server-7.2-x86_64-dvd.iso & # # #安装源指定
[email protected] mnt]# sh vm_create # # #运行脚本
Give script permissions to install virtual machines directly
[Email protected] mnt]# chmod 755 vm_create
[Email protected] mnt]# vm_create test
3. There is a case of node1.qcow2.
[[email protected] mnt]# ls
Node1.qcow2
[Email protected] mnt]# virt-install \
>--name lala \
>--ram 800 \
>--file/mnt/node1.qcow2 \
>--import &
# # # # #管理 # #
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.xml represents the front end management file
Virsh define Vmname.xml # # #永久恢复vm
Virsh undefine vmname # # #删除vm的管理前端, storage is not deleted
[email protected] ~]# Virsh list # # #列出正在运行的vm
Id Name State
----------------------------------------------------
2 LV Running
[email protected] ~]# Virsh list--all # # #列出所有的vm
Id Name State
----------------------------------------------------
2 LV Running
-Desktop shut off
-Server shut off
[email protected] ~]# virsh shutdown LV # # #正常关闭指定vm
Domain LV is being shutdown
[email protected] ~]# Virsh destroy LV # # #强行结束指定vm
Domain LV Destroyed
[email protected] ~]# virsh start LV # # #运行指定vm
Domain LV Started
[email protected] ~]# virt-viewer LV # # #显示指定虚拟机
(virt-viewer:5083): gspice-warning * *: WARNING no automount-inhibiting implementation available
[email protected] mnt]# Virsh Create Lv.xml # # #临时恢复指定前端管理文件
Domain LV created from Lv.xml
[email protected] qemu]# virsh undefine LV # # #删除指定vm前端管理文件, do not delete storage
Domain LV has been undefined
This article is from the "12112684" blog, please be sure to keep this source http://12122684.blog.51cto.com/12112684/1872814
Basics of getting Started with Linux 7