Practical Tips for Linux: Use snapshots to create virtual machines
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
For more details, please continue to read the highlights on the next page: