Common installation and snapshot installation of virtual machines in Linux systems

Source: Internet
Author: User
Tags first string


One, virtual machine installation


1. Image interface Mode

> Add a virtual machine hard disk and change its size to 8G
> Insert Disk
> Read and install the disk
> Boot from hard drive

2. How to edit Scripts


#!/bin/bash# #命令运行环境的指定
virt-install \# #安装虚拟机
--name \# #虚拟机名称指定, representing the first string of characters after the script
--ram# #内存
--file/var/lib/libvirt/images/$1.qcow2, bus=virtio \# #硬盘文件
--file-size 8 \# #硬盘文件大小
--network sourse=br0,model=virtio \
--cdrom/var/ftp/pub/iso/rhel-server-7.1-x86_64-dvd.iso &# #安装源指定


650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024164857777? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>

Second, management

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 is not deleted





# #前端管理文件存放位置:
/etc/libvirt/que
It's got hardware information inside it.
# #后端硬盘文件存放位置:
/var/lib/libvirt/iamges/
The system is installed in the hard disk file

Here's how:
1) Image Interface Recovery

Note: Back-end hard disk files are required

2) File Recovery

Note: The front-end management files and back-end hard disk files need to be backed up before
The recovery process is as follows:
>>Backup front end management files and hard disk files in/mnt/
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024164921488? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024164935773? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024164950557? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
>>Delete Node2 front-end files
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024165010083? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
>>The list of virtual machines in this system is as follows:
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024165024725? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
>>Virtual Machine Recovery
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024165034490? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024165046276? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
>>The list of virtual machines in this system is as follows:
650) this.width=650; "style=" border:;vertical-align:middle; "src=" http://img.blog.csdn.net/20171024165057437? watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>

3) Script Edit recovery


The script is as follows:
#!/bin/bash
Virt-install \
--name node1 \
--ram 1024 \
--FILE/VAR/LIB/LIBVIRT/IMAGES/NODE1.QCOW2 \
--file-size 8 \
--vcpus 1 \
--import &


The graphical interface deletes the front-end management files and the back-end hard disk files as follows:
650) this.width=650; "style=" Font:14px/normal Arial, ' Microsoft Yahei '; Border:;color:rgb (51,51,51); Text-transform: None;text-indent:0px;letter-spacing:normal;word-spacing:0px;vertical-align:middle;white-space:normal; Background-color:rgb (255,255,255); "Src=" http://img.blog.csdn.net/20171024165111750?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvtvltx1n1bnnoaw5l/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "/>

three, virtual machine snapshot

Qemu-img create-f qcow2-b Vm2.qcow2 node1.qcow2
Virtual machine Snapshot principle: The snapshot command generates a snapshot file, which reads the master and makes changes in the snapshot virtual machine, if it is deleted by bad.

1) How to create a snapshot virtual machine:

Generate snapshot file, image mode insert Build
Directly edit the script file, run the next key to generate

The process is as follows:
@@ 法 One
[Email protected] mnt]# vim create_vm.sh
[Email protected] mnt]#/create_vm.sh haha
Success
[email protected] mnt]# cat create_vm.sh
#!/bin/bash
qemu-img create-f qcow2-b/var/lib/libvirt/images/node1.qcow \
/var/lib/libvirt/images/$1.qcow &>/dev/null

Virt-install \
--name \
--ram 1024 \
--file/var/lib/libvirt/images/$1.qcow \
--file-size 8 \
--import &>/dev/null &
Echo Success


@@ 法 Two
To do this, you can also edit the script file in the following ways:
#!/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 &


This article is from the "13402758" blog, please be sure to keep this source http://13412758.blog.51cto.com/13402758/1976310

Common installation and snapshot installation of virtual machines in Linux systems

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.