Practical Tips for linux: practical tips for using snapshots to create virtual machines and linux
In daily learning, if you encounter cluster and load balancing experiments, you need to use a large number of virtual machines. If you create one by one, it is obviously very cost-effective and inefficient. So how can we use snapshots to create virtual machines today. The number of bytes _ ^ you want. As long as the memory is enough!
To create a snapshot of a VM, perform the following steps:
1. First, we need to create a stored logical volume to generate the template and snapshot file;
2. Create a snapshot template;
3. Create a snapshot.
1. Create a logical volume:
(1) fdisk/dev/sda (create an LVM logical volume and then re-scan the disk ;)
(2) partx-d/dev/sda
Partx-a/dev/sda
(3) create an lv file:
Pvcreate/dev/sda
Vgcreate-s 4 M vg1/dev/sda5
Lvcreate-L 10G-n base vg1
(4) Then you can create a virtual machine template:
In this case, you can install an ordinary virtual machine. After the restart, perform the following operations (because you have created a template, the template must be universal)
2. Create a template:
In the template virtual machine, perform the following operations:
1. Disable firewall and selinux (File Modification ):
Vim/etc/sysconfig/selinux
2. Modify the network configuration file and delete the NIC 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 template is completed, you can use a snapshot to take a photo of it on the real machine. However, you must disable the template before taking the photo, usually, when we take a photo of a person, we also need his static ^_^.
Select the snapshot file:
Directly start vm2 and enable it instantly. Its status is the initial status of the template, which is very convenient.
Let's calculate the total overhead:
Template (10 Gb)
In the future, each virtual machine only needs 4 GB or so, so that many virtual machines can be created. No installation is required, which greatly saves space.
Conclusion:
Let's try it out.
How to Create snapshots in a virtual machine
Three buttons: Create a snapshot, restore a snapshot, and manage a snapshot. Very simple.
How to Use vmwarevm snapshots?
A snapshot can hold your system in a certain state! The 1st button is used to create a snapshot. The 2nd button is used to return to the current snapshot. The 3rd button is used to manage all your snapshots.