1)
-bash-4.2# lscpu | grep Virtualization
Virtualization: VT-x
-bash-4.2#
2) Install packages / binaries
yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install
3) start services
systemctl enable libvirtd
systemctl start libvirtd
3) Verify KVM installation
-bash-4.2# lsmod | grep -i kvm
kvm_intel 174841 0
kvm 578518 1 kvm_intel
irqbypass 13503 1 kvm
-bash-4.2#
4) Configure bridged networking
-bash-4.2# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.0242acffc174 no
virbr0 8000.52540058ad34 yes virbr0-nic
-bash-4.2# virsh net-list
Name State Autostart Persistent
———————————————————-
default active yes yes
-bash-4.2#
5) All VMs (guest machine) only have network access to other VMs on the same server. A private network 192.168.122.0/24 created for you. Verify it
-bash-4.2# virsh net-dumpxml default
<network>
<name>default</name>
<uuid>5b3f1a22-6392-447c-83c1-6fb90847f1df</uuid>
<forward mode=’nat’>
<nat>
<port start=’1024′ end=’65535’/>
</nat>
</forward>
<bridge name=’virbr0′ stp=’on’ delay=’0’/>
<mac address=’52:54:00:58:ad:34’/>
<ip address=’192.168.122.1′ netmask=’255.255.255.0′>
<dhcp>
<range start=’192.168.122.2′ end=’192.168.122.254’/>
</dhcp>
</ip>
</network>
-bash-4.2#
6) Create a bridge on your LAN, so that your VM has access to outside host world
vi /etc/sysconfig/network-scripts/ifcfg-eno2 (take backup before altering it)
add line:
BRIDGE=br0
vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0" # I am getting ip from DHCP server # BOOTPROTO="dhcp" IPV6INIT="yes" IPV6_AUTOCONF="yes" ONBOOT="yes" TYPE="Bridge" DELAY="0"
7) restart n/w manager
systemctl restart NetworkManager
8) verify using below command
-bash-4.2# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000000000000 no
docker0 8000.0242acffc174 no
virbr0 8000.52540058ad34 yes virbr0-nic
-bash-4.2#
9)
In this example, I’m creating RHEL 7.5 VM with 2GB RAM, 2 CPU core, 1 nic and 40GB disk space, enter
Download RHEL7.5 iso file and place it in below:
/var/lib/libvirt/boot/
-bash-4.2# ls -lrt /var/lib/libvirt/boot/
total 0
-bash-4.2#
After download:
-bash-4.2# ls -lrt /var/lib/libvirt/boot/
total 4509696
-rw-r–r–. 1 root root 4617928704 Mar 22 2018 RHEL-7.5-20180322.0-Server-x86_64-dvd1.iso
-bash-4.2#
10) Issue seen while provisioning rhel7 VM
-bash-4.2# virt-install \
virt-install –virt-type=kvm –name rhel7 –memory=2048,maxmemory=4096 –vcpus=2 –os-variant=rhel7.5 –cdrom=/var/lib/libvirt/boot/RHEL-7.5-20180322.0-Server-x86_64-dvd1.iso –network=bridge=virbr0,model=virtio –graphics vnc –disk path=/var/lib/libvirt/images/rhel7.qcow2,size=40,bus=virtio,format=qcow2
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (40960 M requested capacity > 25473 M available)
ERROR The requested volume capacity will exceed the available pool space when the volume is fully allocated. (40960 M requested capacity > 25473 M available) (Use –check disk_size=off or –check all=off to override)
-bash-4.2#
Solution: find some free space on any of your partitions and create a symbolic link to that path in the virtual drive required for the VM
-bash-4.2# mkdir -p /home/media-rhel7.5/images
-bash-4.2#
Before linking to free partition, space on the virtual drive. It has 26GB but we need 40GB
-bash-4.2# df -h /var/lib/libvirt/images/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 26G 25G 51% /
-bash-4.2#
Free pace available under /home:
bash-4.2# df -h /home/media-rhel7.5/images
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-home 318G 263G 55G 83% /home
-bash-4.2#
-bash-4.2# ln -fs /var/lib/libvirt/images/ .
-bash-4.2# ls -lrt
total 0
lrwxrwxrwx. 1 root root 24 Feb 18 04:44 images -> /var/lib/libvirt/images/
-bash-4.2# pwd
/home/media-rhel7.5/images
-bash-4.2#
-bash-4.2# ls -lrt
total 0
lrwxrwxrwx. 1 root root 26 Feb 18 04:54 images -> /home/media-rhel7.5/images
-bash-4.2# pwd
/var/lib/libvirt/images
-bash-4.2#
11) Above didn’t work so i requested for 20 GB space:
virt-install \
–virt-type=kvm \
–name rhel75 \
–memory=2048,maxmemory=4096 \
–vcpus=2 \
–os-variant=rhel7.5 \
–cdrom=/var/lib/libvirt/boot/RHEL-7.5-20180322.0-Server-x86_64-dvd1.iso \
–network=bridge=virbr0,model=virtio \
–graphics vnc \
–disk path=/var/lib/libvirt/images/rhel7.qcow2,size=20,bus=virtio,format=qcow2
12)
-bash-4.2# sudo virsh dumpxml rhel7 | grep vnc
<graphics type=’vnc’ port=’5900′ autoport=’yes’ listen=’127.0.0.1′>
-bash-4.2#
13) How to share files with host and guest rhel7.5 kvm host and rhel7 guest
http://nts.strzibny.name/how-to-set-up-shared-folders-in-virt-manager/
https://www.cyberciti.biz/faq/how-to-add-disk-image-to-kvm-virtual-machine-with-virsh-command/
Reference Link:
https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-7-rhel-7-headless-server/
https://forums.fedoraforum.org/showthread.php?318506-Trying-to-use-virtualization-and-installing-VMs
share files b/w host and VMs: