Rockstor as a Virtualization Host Made Easy – Setup Guide Using KVM/QEMU & Cockpit for Running & Managing Virtual Machines

Introduction

Having the ability to run some virtual machines (VM) on top of Rockstor is a frequently requested feature, especially when comparing Rockstor to other NAS operating systems (OS).

I deeply respect the decision of the Rockstor development team to focus on the BTRFS RAID & NAS functionality without providing another VM interface and exactly for this reason - being the only NAS OS utilizing the unique advantages of BTRFS to it’s fullest potential - I do use and love the Rockstor OS.

With the upgrade to Rockstor built on openSUSE 15.6 it is easier than ever to add this VM functionality on top by installing some stable packages from default repositories that transform Rockstor into a full-fledged Virtualization Host including a web-UI for managing & interfacing with the VMs.

Prerequisites

This is a tutorial using (1) kvm/qemu as virtual machine hypervisor and (2) cockpit web-UI as management interface.

Each of these tools can be installed and used on it’s own. While it was with earlier Rockstor versions already possible to use kvm/qemu for virtualization on Rockstor, it is cockpit that was not supported in previous versions of openSUSE Leap and therefore requires a Rockstor version that is is built on Leap 15.6.

All following commands must be executed in a shell (e.g. SSH or via Rockstor web-UI: System > Shell) as root (e.g. (a) logging in as root, (b) typing su to become root or (c) install sudo manually zypper in --no-recommends sudo).

Note: If sudo is not installed manually on Rockstor, then the sudo from all following commands must be omitted.

Software Installation

Install the following 3 packages - no need to modify / add any of the package repositories

sudo zypper in --no-recommends yast2-vm cockpit cockpit-machines

KVM/QEMU Setup

Use the yast2 tool from openSUSE to set up a virtual machine hypervisor:

sudo yast2

Then select “Virtualization” (on the keyboard use the down arrow and confirm with Enter) > “Install hypervisor and Tools”

In the next screen select (Tab to cycle through the options and Enter to select the checkbox) “KVM server” and “KVM tools”

Then you are asked about installing graphical components - as they are not needed on a server, select “No”

During installation there will be a warning reading:

NetworkManager is being used. Bridge configuration must be done manually

=> this is fine, simply confirm with Enter

When finished, quit yast2 by pressing the F9 Key


To allow your (Rockstor) user to manage the VMs, add this user to the libvirt group by replacing <username> with your username in the following command:

sudo usermod -aG libvirt <username>

And reboot your machine for the group modification to take effect (either now, or at some point before using cockpit for setting up VMs)


Additionally, the modular libvirt deamons (which are used by openSUSE Leap 15.6) must be enabled manually:

for drv in qemu network nodedev nwfilter secret storage
do
 sudo systemctl enable --now virt${drv}d.service
 sudo systemctl enable --now virt${drv}d{,-ro,-admin}.socket
done

Cockpit Setup

The cockpit socket just needs to be enabled with:

sudo systemctl enable --now cockpit.socket

Bug-Workaround - Cockpit Version 321 (as of 27. September 2024)
There is currently a known Bug in the openSUSE cockpit package regarding the change of the cockpit username. I assume this will be fixed in the next weeks.

Symptom: the cockpit web-UI will not load and the cockpit.socket is stopped after one tries to connect to the web-UI

As a workaround, modify the lines of /etc/nsswitch.conf to the following:

passwd:         compat systemd
group:          compat [SUCCESS=merge] systemd
shadow:         compat systemd

End of Bug-Workaround


Cockpit Web-UI

That’s it with the “hard” part, we now have (additionally to the Rockstor web-UI) the cockpit web-UI for managing all kind of OS related things, from Services to Virtual Machines and an extensive List of Cockpit-Applications to chose from.

Connecting to the web-UI

Connect to cockpit via port 9090 (the same way as accessing Rockstor web-UI, but with :9090 appended) - e.g. in your browser type: https://<ip-addr>:9090

Cockpit will force you to use HTTPS and you therefore have to accept the self-signed certificate.

On the log-in page use your Rockstor username & password to log-in


There are many different resources about using cockpit including official guides from SUSE Linux Enterprise and Redhat (web console = cockpit)

Set-Up a Virtual Machine using Cockpit

Network Configuration

Remember the warning about the bridge configuration? We now have to recreate the bridge network from the cockpit web-UI:

  1. after logging-in, turn on administrative access by clicking the Symbol: “:lock: Limited Access” and enter the root password of rockstor

  2. select Virtual machines > Networks > and delete the “default” network

  3. click “Create virtual network” (which is only possible with Administrative access) and to make your life easier call it “default” again, keep the other fields at their default value but enable DHCP and set a sensible range - e.g.:

  4. press on “Activate” and confirm that the State has changed to active

  5. optionally set “Autostart” for this network by expanding the network in list-view with the small arrow on the left and select the according switch (“Run when host boots”)

  6. you can now switch back to limited access by clicking on “Administrative access” in the top bar.

Create VM

Select “Virtual machines” > “Create VM” to set up a new VM:


Click “Create and run” to start up your VM with default settings or press “Create and edit” to modify advanced settings like virtual network interfaces and CPU count.

After starting up the VM, you can use the integrated Console to connect to the VM

Congratulation, your Rockstor server is now also a great Virtual Machine Hypervisor :partying_face: :tada: - have fun

Cheers
Simon

4 Likes