KVM virtualization on Fedora 24 + Gnome Boxes

Hi Everybody!!

As Linux users we have a native virtualization solution -like MS windows have hiper-v-  KVM.

KVM (kernel based virtualization) is a kernel module takes advantage of the x86 processors virtualization extensions like Intel VT-x and  AMD-V, so let’s go:

Requirements:

  • a 64-bit x86 machine with hardware virtualization assistance (Intel VT-X or AMD-V).
  • 4GB RAM (8 GB or more if you want to run more than 2 virtual machines at same time)
  • One ISO file of your favorite OS.

Step Zero:

Enable Intel VT-x or AMD-V Virtualization in BIOS/UEFI, this depends of your hardware but to enable the extensions, you might have to go into the system’s BIOS/UEFI setup configuration at boot time.

Step One:

Install KVM and virtualization tools:

$ sudo dnf install @virtualization virt-install virt-viewer libvirt-daemon-config-network

$ sudo systemctl enable libvirtd

$ sudo systemctl start libvirtd

Check that libvirtd is running:

$ sudo systemctl status libvirtd 

this will be up and running.

Optional but recommend step:

Add your normal user to libvirtd group, please change YOURUSER for your username

$ sudo usermod -a -G libvirt YOURUSER

Step Two:

Create and configure virtual machine:

For this we have two options: Command line and GUI, in order to show both examples i will create two separate virtual machines: Fedora Server 24 (Command line) and Ubuntu Server16.04.

Command Line:

To setup a virtual machine named FedoraServer24 with 2GB ram, 2 VCPUS, 20GB in hard disk in format qcow2 (Compatible with OpenStack)

$ cp Fedora-Server-dvd-x86_64-24-1.2.iso /tmp/
$ sudo virt-install --name FedoraServer24 --ram 2048 --vcpus 2 --disk size=20,format=qcow2 --cdrom /tmp/Fedora-Server-dvd-x86_64-24-1.2.iso --virt-type kvm --os-variant fedora-unknown --graphics spice

You can list the supported os variants with:

$ osinfo-query os

or simply use ‘auto’ keyword for auto detection.

At this moment you will continue the normal installation of Fedora Server

Screenshot from 2016-07-12 15-52-45Screenshot from 2016-07-12 16-05-54

virt-manager GUI

Is too easy, open virtual machine manager,it looks like:

Screenshot from 2016-07-12 16-42-15Screenshot from 2016-07-12 16-47-07Screenshot from 2016-07-12 17-03-07Screenshot from 2016-07-12 17-04-07

After :

  1. click on “Create new virtual machine”
  2. install local media (ISO image or cdrom)
  3. Select iso image and Browse it (Ubuntu server 16.04 in this time)
  4. Setup RAM, virtual Hard disk , vcpus and Name of the Virtual Machine.

At this moment you will continue the normal installation of Ubuntu Server.

Step Three:

Connect and working with the virtual machines:

Command line:

List virtual machines:

$ sudo sudo virsh list --all

Start, pause, shutdown virtual machines

$ virsh --connect qemu:///system start FedoraServer24

$ virsh --connect qemu:///system suspend FedoraServer24

$ virsh --connect qemu:///system shutdown FedoraServer24

View and work in the virtual machine

$ virt-viewer --connect qemu:///system  FedoraServer24

virt-manager GUI

The available virtual machines are listed on the gui, to run or stop, right click over the desired virtual machine. for work in any particular virtual machine click open.

Step Four:

KVM/libvirt Networking: The default network configuration is for the VM to share the host system’s network connection(s) and IP address using network address translation (NAT). This is the easiest to manage and will be fine for many uses. Using NAT, the VM will be able to access resources on your network or the Internet. However services, such as a web server, running inside the VM won’t be directly accessible from outside of the VM.

For default all virtual machines are in the same LAN and it can communicate each other one another:

Screenshot from 2016-07-12 18-11-41

Networking, both physical and virtual, is a large topic beyond the scope of this post. For more information see your system’s documentation.

Gnome Boxes

Boxes is a GNOME application (It comes by default since Fedora 23) that is used to create, manage, and run virtual machines. One amazing feature is it can easily import and run KVM virtual machines.

for this:

  1. Open Boxes
  2. Click on New
  3. Click on “Import Boxes from system broker”
  4. And finally, Click on “Create”

Screenshot from 2016-07-12 18-28-26Screenshot from 2016-07-12 18-32-11

And now you can run the same virtual machines from Gnome Boxes.

Cheers!!

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.