Linux rookie starter virtual machines and scripts

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.