Reprinted: https://blog.csdn.net/sunnyfg/article/details/51493602
1. Host environment description:
Operating system: CentOS7
System GUI: none
CPU: Intel 4th generation, memory: 16G, hard disk 1T
Host IP address: 192.168.0.95 (intranet)
Enabled services: ssh, ftp, samba shares (the shared directory is /var/data/test1, and the permissions are readable and writable)
2. Preparations
install kvm
- $ sudo yum -y install qemu-kvm libvirt virt-install bridge-utils virt-install
- $ sudo systemctl start libvirtd
- $ sudo systemctl enable libvirtd
3. Add a bridge network card, named br0
- $ sudo nano /etc/sysconfig/network-scripts/ifcfg-br0
- DEVICE=br0
- TYPE=Bridge
- BOOTPROTO=none
- ONBOOT=yes
- IPADDR=192.168.0.223
- NETMASK=255.255.255.0
- GATEWAY=192.168.0.1
4. Restart the network
- $ sudo systemctl restart <span style="font-family: Arial, Helvetica, sans-serif;">network</span>
5. Upload the system image to the shared directory /var/data/test1.
Since the samba sharing service is enabled, you only need to open the share on other machines in the local area network.
Use "\\192.168.0.95" directly under windows
Use smb://192.168.0.95 under Linux
Open the network in Finder under Mac and you can find it
If samba has set users and access rights, please log in with the corresponding user and password
Copy the system installation image to /var/data/test
6. Start the installation
- $ sudo virt-install \
- --name=CentOS7 \
- --controller type=scsi,model=virtio-scsi \
- --disk path=/var/lib/libvirt/images/CentOS7.dsk,size=20,sparse=true,cache=none,bus=scsi \
- --graphics vnc,listen=0.0.0.0,port=5950 \
- --network bridge=kvm01 \
- --vcpus=2 --ram=2048 \
- --cdrom = / var / data / test1 / CentOS7.iso \
- --os-type = linux \
- --os-variant=rhel7
Parameter Description:
name--->Virtual machine name
disk path----->virtual hard disk storage path, the suffix name can be arbitrary
size-----> virtual hard disk size (unit is G)
port----->vnc port
vcpus--->Number of system cores
ram------> running memory
cdrom---->Installation package location
os-variant-----> Since CentOS is based on Redhat, it corresponds to its version
7. Next, use vnc to connect, the IP is 192.168.0.223, the port is 5950, no user password is required, and then the familiar installation interface will appear.