Install Virtual Machine in CentOS7 Command Line Mode

 

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

[plain] view plain copy
  1. $ sudo yum -y install qemu-kvm libvirt virt-install bridge-utils virt-install  
  2. $ sudo systemctl start libvirtd   
  3. $ sudo systemctl enable libvirtd  


3. Add a bridge network card, named br0

[html] view plain copy
  1. $ sudo nano /etc/sysconfig/network-scripts/ifcfg-br0  
[html] view plain copy
  1. DEVICE=br0  
  2. TYPE=Bridge  
  3. BOOTPROTO=none  
  4. ONBOOT=yes  
  5. IPADDR=192.168.0.223  
  6. NETMASK=255.255.255.0  
  7. GATEWAY=192.168.0.1  


4. Restart the network

[plain] view plain copy
  1. $ 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

[plain] view plain copy
  1. $ sudo virt-install \  
  2.    --name=CentOS7 \  
  3.    --controller type=scsi,model=virtio-scsi \  
  4.    --disk path=/var/lib/libvirt/images/CentOS7.dsk,size=20,sparse=true,cache=none,bus=scsi \  
  5.    --graphics vnc,listen=0.0.0.0,port=5950 \  
  6.    --network bridge=kvm01 \  
  7.    --vcpus=2 --ram=2048 \  
  8.    --cdrom = / var / data / test1 / CentOS7.iso \  
  9.    --os-type = linux \  
  10.    --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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325310068&siteId=291194637