System Virtual Machine Management
1. Installation
#!/bin/bash
Virt-install \
--name \
--ram 1000 \
--FILE/VAR/LIB/LIBVIRT/IMAGE/$1.IMG \
--file-size 8 \
--cdrom/var/ftp/pub/iso/
2. Management
Virt-manager Opening the Graphics management tool
Virt-viewer display virtual machine, vmname-virtual machine name
Virsh List List of running VMS
Virsh List List of all VMS
Virsh start Vmname Run the specified VM
Virsh shutdown normal shutdown of the specified VM
Virsh destroy Force shutdown specified
Virsh Create Vmname.xml temporarily restores the specified VM Vmname represents the front end management file
Virsh define Vmname.xml permanently recover VMS
Virsh undefine Vmname Delete the front-end management of the VM and does not delete the storage
3. Virtual Machine Snapshots
Qemu-img create-f qcow2-b Vm2.qcow2 node.qcow2
Scripting: Implementing multiple functions with case statements
#!/bin/bash
Case "$" in
Deladd)
Echo Poweroff $
Virsh Destroy $ &>/dev/null
Echo del $1.xml ...
Virsh undefine $ &>/dev/null
echo Create disk.
Qemu-img create-f qcow2-b/var/lib/libvirt/images/$1.qcow2/var/lib/libvirt/images/$2.qcow2 &>/dev/null
ECHO Create VMs
Virt-install \
--name
--ram 1000 \
--DISK/VAR/LIB/LIBVIRT/IMAGES/$2.QCOW2 \
--import &>/dev/null &
Echo create $ successful;;
Create
Virt-install \
--name \
--ram 1000 \
--FILE/VAR/LIB/LIBVIRT/IMAGES/$1.QCOW2 \
--file-size 8 \
--cdrom/home/kiosk/desktop/rhel-server-7.1-x86_64-dvd.iso &
Echo create $ successful;;
Createdisk)
Qemu-img create-f qcow2-b/var/lib/libvirt/images/$1.qcow2/var/lib/libvirt/images/$2.qcow2 &>/dev/null
echo Create $ sucessful;;
Poweroff
Virsh Shutdown $ &>/dev/null
Echo already shutdown $
Esac
This article is from the "12147236" blog, please be sure to keep this source http://12157236.blog.51cto.com/12147236/1863529
Linux rookie starter virtual machines and scripts