- CentOS Setup
Remember to add the user to administrator group when create an user.
-
List ethernet card
nmcli d
-
Open Network manager and edit connection.
nmtui
Choose “Automatic” in IPv4 CONFIGURATION and check Automatically connect check box and press OK and quit from Network manager.
-
Reset network service
service network restart
-
Forwarding external port to port 22 manually. This setup is not necessary if the router has the capability of forwarding ports.
firewall-cmd --zone=public --add-masquerade --permanent firewall-cmd --zone=public --add-forward-port=port=6301:proto=tcp:toport=22 --permanent firewall-cmd --reload
-
List available package groups
yum group list
-
Install Gnome GUI packages
yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
-
Enable GUI on system startup
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
-
Reboot the machine to start the server in the graphical mode
reboot
-
Disabling NetworkManager
chkconfig NetworkManager off chkconfig network on service NetworkManager stop service network start
-
Open ifcfg-em1 (or ifcfg-eth0 depending on what ethernet card you have) in /etc/sysconfig/network-scripts. Make the following changes.
#TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no #BOOTPROTO=dhcp <-------------It is very important to change dhcp to static BOOTPROTO=static #DEFROUTE=yes #IPV4_FAILURE_FATAL=no #IPV6INIT=yes #IPV6_AUTOCONF=yes #IPV6_DEFROUTE=yes #IPV6_FAILURE_FATAL=no #IPV6_ADDR_GEN_MODE=stable-privacy NAME=em1 UUID=7c87469d-30c3-453f-854a-104142f03bee DEVICE=em1 ONBOOT=yes BRIDGE=br0 <---------------This line is also very important
-
Modify/Create ifcfg-br0 in the same folder to define bridge device
DEVICE="br0" BOOTPROTO=static IPV6INIT=yes IPV6_AUTOCONF=yes ONBOOT=yes TYPE=Bridge DELAY=0 IPADDR=192.168.29.190 NETMASK=255.255.255.0 GATEWAY=192.168.29.1
-
Restart networking
service network restart
-
Check shared physical device
brctl show
A table that similar to the following should show up
bridge name bridge id STP enabled interfaces br0 8000.f8b156c47f7d no em1 vnet0 vnet1 virbr0 8000.5254006ad49e yes virbr0-nic
-
Install KVM
yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install
-
Start the libvirtd service
systemctl enable libvirtd systemctl start libvirtd
-
Verify kvm installation. Make sure KVM module loaded using lsmod command and grep command.
lsmod | grep -i kvm
-
Direct to /var/lib/libvirt/images, and download CentOS image from web.
cd /var/lib/libvirt/images wget http://mirror.trouble-free.net/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso
-
Use
virt-install
to create VMvirt-install \ --virt-type=kvm \ --name centos7 \ --ram 2048 \ --vcpus=1 \ --os-variant=centos7.0 \ --cdrom=/var/lib/libvirt/boot/CentOS-7-x86_64-Minimal-1804.iso \ --network=bridge=br0,model=virtio \ --graphics vnc \ --disk path=/var/lib/libvirt/images/centos7.qcow2,size=40,bus=virtio,format=qcow2
-
Intall virt-viewer
yum install virt-viewer
-
Launch VM with virt-viewer
virt-viewer --domain-name VMName
-
Install virt-manager
yum install virt-manager
-
Start virt-manager
virt-manager
-
Follow the UI instructions to create VM
-
Repeat the process of Setup network to setup network for VM.
-
Open ifcfg-em1 (or ifcfg-eth0 depending on what ethernet card you have) in /etc/sysconfig/network-scripts. Make the following changes. NOTE: Unlike the step described in Bridge network, the change of ifcfg-em1 (or ifcfg-eth0) do not need a bridge.
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static <---------- change dhcp to static is important #DEFROUTE=yes #IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes #IPV6_DEFROUTE=yes #IPV6_FAILURE_FATAL=no #IPV6_ADDR_GEN_MODE=stable-privacy NAME=eth0 UUID=a71e47e3-8622-459b-b9b3-a1b41f93fa64 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.29.192 <------------ assign an address for VM NETMASK=255.255.255.0 GATEWAY=192.168.29.1 DNS1=192.168.29.1
Repeat the process of Setup UI to setup UI for VM. NOTE: again this step is only needed if use CentOS minimal.
Using virt-clone
to clone a guest. NOTE: Before proceeding with cloning, shut down the virtual machine.
virt-clone --original srcVMName --name newVMName --auto-clone
Refer to this link for clone VM via GUI.
- If you are using commandline, first, run
virt-viewer
to launch the cloned VM.
virt-viewer --domain-name newVMName
-
Open ifcfg-em1 (or ifcfg-eth0 depending on what ethernet card you have) in /etc/sysconfig/network-scripts, and modify the value of IPADDR.
-
Restart network service
service network restart
-
Check connectivity to host machine. Use the
router address
ssh -p 6701 [email protected]
-
Check connectivity to guest machine. Use the
static address
that assigned to each machine.
Setup network: https://lintut.com/how-to-setup-network-after-rhelcentos-7-minimal-installation/
Setup UI:https://www.itzgeek.com/how-tos/linux/centos-how-tos/install-gnome-gui-on-centos-7-rhel-7.html
Bridge network: https://wiki.libvirt.org/page/Networking#Bridged_networking_.28aka_.22shared_physical_device.22.29
Create VM: https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-7-rhel-7-headless-server/ https://www.linuxtechi.com/install-kvm-hypervisor-on-centos-7-and-rhel-7/