Linux tips: Using snapshots to make virtual machines

Source: Internet
Author: User

In daily learning, if you encounter cluster and load balancing experiments, you need to use a lot of virtual machines, if one to create, it is obviously very laborious and inefficient. So today we give you how to use snapshots to make virtual machines. How much you want to ^_^. As long as the memory is enough!

The snapshot of a virtual machine is divided into the following steps:

1. First we will create a stored logical volume to generate the template and snapshot files;
2. Make the template of the snapshot;
3. Create a snapshot.

1. Create a logical Volume:

(1) FDISK/DEV/SDA (make LVM logical volume, then scan the disk again;)


(2) partx-d/DEV/SDA
Partx-a/DEV/SDA

(3) Create the LV file:

Pvcreate/dev/sda
Vgcreate-s 4M Vg1/dev/sda5
Lvcreate-l 10g-n Base Vg1

(4) You can then create a virtual machine template:





This time you can install a normal virtual machine like. What to do once the reboot is complete (because you're making a template, so the template has to be universal)

2. Create a Template:

There are a few things to do in the template virtual machine:

1. Close firewall and SELinux (modified in file):



Vim/etc/sysconfig/selinux


2. Modify the network configuration file and delete the network card information:

Vim/etc/sysconfig/network-script/ifcfg-eth0




3. Modify the Yum source to a stable address:

Vim/etc/yum.repos.d/yum.repo





3. Create a Snapshot:

After the completion of our template has been completed, this time on the real machine with a snapshot of it to take pictures, but before taking the picture must be closed off, usually we give a picture of the time is also to his static ^_^.





Select our Snapshot file:



Direct start vm2, instantly open, his state is the initial state of the template, very convenient.


Let's calculate the total cost:

Template (10G)
In the future, each virtual machine needs to be about 4G, which makes a lot of virtual machines. No installation is required, and space overhead is greatly reduced.


Conclusion:

Let's go to practice for the little friends.







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.