Install virtual machines in CentOS7 Command Line Mode
1. host environment description:
Operating System: CentOS7
System GUI: None
CPU: Intel4 generation, memory: 16 GB, Hard Disk 1 Tb
Host IP Address: 192.168.0.95 (Intranet)
Services enabled: ssh, ftp, and samba sharing (the shared directory is/var/data/test1 and the permission is read/write)
2. Preparations
Install kvm
[Plain] view plaincopy
- $ Sudoyum-yinstallqemu-kvmlib1_virt-installbridge-utilsvirt-install
- $ Sudosystemctlstartlibvirtd
- $ Sudosystemctlenablelibw.d
3. Add a bridge Nic named br0
[Html] view plaincopy
- $ Sudonano/etc/sysconfig/network-scripts/ifcfg-br0
[Html] view plaincopy
- 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
[Plain] view plaincopy
- $ Sudosystemctlnetworkrestart
5. Upload the system image to the shared directory/var/data/test1.
Because the samba sharing service is enabled, you only need to enable sharing on other machines in the LAN.
Use "\ 192.168.0.95" in windows"
Use smb in Linux: // 192.168.0.95
You can find
If samba has set user and access permissions, use the corresponding user and password to log on.
Copy the system installation image to/var/data/test
6. Start Installation
[Plain] view plaincopy
- $ Sudovirt-install \
- -- Name = CentOS7 \
- -- Controllertype = scsi, model = virtio-scsi \
- -- Diskpath =/var/lib/libvirt/images/CentOS7.dsk, size = 20, sparse = true, cache = none, bus = scsi \
- -- Graphicsvnc, listen = 0.0.0.0, port = 5950 \
- -- Networkbridge = 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 with any suffix
Size -----> virtual hard disk size (in G)
Port -----> vnc port
Vcpus ---> Number of system kernels
Ram ------> running memory
Cdrom ----> Installation Package location
OS-variant -----> because CentOS is based on Redhat, it corresponds to its version