Skip to content

4. Virtualization

D3vil0p3r edited this page Apr 15, 2023 · 8 revisions

Athena OS can be used also on virtualization platforms as VirtualBox, VMware Workstation, QEMU, and so on.

Some of them are not easy to configure and the correct steps for using them are shown in the next sections.

QEMU (Windows Host)

For using QEMU on Windows Host, it is important to enable Virtualization by the BIOS and have Hyper-V enabled in order to use WHPX as accelerator.

First, reboot and access to your BIOS, select the Virtualization Technology, Intel Virtual Technology, or SVM Mode option (the feature name will depend on your manufacturer). Enable the virtualization feature. Save configuration and reboot.

After reboot, when landed on Windows, create a file called hyperv-home.bat with the following content:

pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hv-home.txt
for /f %%i in ('findstr /i . hv-home.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hv-home.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause

Run it. This script will download and install Hyper-V feature if your Windows does not have it.

Then, by Windows search bar reach Turn Windows features on or off and check for Hyper-V, Virtual Machine Platform and Windows Hypervisor Platform. Click OK and reboot.

Open PowerShell as Administrator and run bcdedit /enum and be sure that hypervisorlaunchtype is set to Auto (that means "ON"). If not, run bcdedit /set hypervisorlaunchtype auto.

Now install QEMU for Windows from the official website. After the installation, go to the Windows search bar and reach Edit the system environment variables. Click on Environment Variables..., go to Path, click on Edit..., click on New and add the QEMU installation path (by default is: C:\Program Files\qemu). Click OK on all opened windows.

Since it could be very useful running our Athena OS by UEFI, we need to retrieve UEFI libraries for allowing QEMU to work in UEFI mode. For doing this, from https://www.kraxel.org/repos/jenkins/edk2/ download the latest version of edk2.git-ovmf-x64-0-20220719.209.gf0064ac3af.EOL.no.nore.updates.noarch.rpm file, then by 7zip, extract the content in a new folder. You will get a .cpio file. Again, by 7zip, extract the content of this .cpio file in a folder. It will contain our .fd file for allowing QEMU to run in UEFI mode. We will use the path to this file in the final QEMU command.

Now it is all set for running Athena OS on QEMU!

Open PowerShell. For first we need to create a disk where we must install Athena OS. Do it by running:

qemu-img create -f qcow2 athena30.img 30G 

30G is the disk space we would like to assign to the disk. athena30.img will be created in the current directory but if you wish, you can type the entire path you would like to store it.

Now, we can run Athena OS by QEMU:

qemu-system-x86_64.exe -boot order=dc -hda .\athena30.img -cdrom .\VirtualShare\athena-2023.01.23-x86_64.iso -m 4G -accel whpx,kernel-irqchip=off -smp 2 -device VGA -device qemu-xhci -bios C:\Users\<USERNAME>\Downloads\edk2.git-ovmf-x64-0-20220719.209.gf0064ac3af.EOL.no.nore.updates.noarch\usr\share\edk2.git\ovmf-x64\OVMF_CODE-pure-efi.fd -cpu Nehalem -chardev socket,id=qga0,server=on,wait=off -device virtio-serial-pci,id=virtio-serial0 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=qga0,id=channel0,name=org.qemu.guest_agent.0

By this command, QEMU will boot the Athena OS ISO that we use for installing Athena. After the installation, turn off the virtual machine and, for booting directly to the Athena OS disk, just remove -cdrom <path-to-iso> argument. The final QEMU command to call is:

qemu-system-x86_64.exe -boot order=c -hda .\athena30.img -m 4G -accel whpx,kernel-irqchip=off -smp 2 -device VGA -device qemu-xhci -bios 'C:\Users\Username\Downloads\edk2.git-ovmf-x64-0-20220719.209.gf0064ac3af.EOL.no.nore.updates.noarch\usr\share\edk2.git\ovmf-x64\OVMF_CODE-pure-efi.fd' -cpu Nehalem -chardev socket,id=qga0,server=on,wait=off -device virtio-serial-pci,id=virtio-serial0 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=qga0,id=channel0,name=org.qemu.guest_agent.0

The command above enables the virtual machine to use QEMU Guest Agent. In general, a Linux distro that would like to use it, need to install qemu-guest-agent package, then run sudo systemctl restart qemu-guest-agent. At the end, just verify it is active by running sudo systemctl status qemu-guest-agent.

QEMU Parameters

Parameter Description
-boot order=dc Set the boot order. d refers to the -cdrom entry and c to the -hda entry.
-hda <path-to-img> Specify the disk to boot.
-cdrom <path-to-iso> Specify the ISO to boot.
-m <size> Set the RAM size.
-accel <accelerator> Specify the accelerator to use.
-smp <core-number> Set the number of cores to use.
-bios <path-to-bios-mode-file> Specify the BIOS mode to use (i.e., UEFI).
-cpu <CPU type> Set the CPU type to use.
-chardev socket,id=qga0,server=on,wait=off -device virtio-serial-pci,id=virtio-serial0 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=qga0,id=channel0,name=org.qemu.guest_agent.0 Enable the usage of QEMU Guest Agent.

Limitations

The main disadvantage of using QEMU on a Windows host does not allow to perform a GPU Passthrough, it means that all virtual machines running there will work by Software Rendering as graphics.

Useful Links

QEMU (Linux Host)

For first, install QEMU-related packages:

sudo pacman -S qemu-full virt-manager dnsmasq

Then, run the right services:

sudo systemctl enable libvirtd
sudo systemctl start libvirtd
sudo systemctl enable dnsmasq
sudo systemctl start dnsmasq

For creating a virtual machine, open Virtual Manager, click on File -> New Virtual Machine, then:

  • expand Architecture options and select the architecture you need, and keep Local install media (ISO image or CDROM) option and click Forward;
  • click Browse... and select for the ISO, then choose the operating system you are installing on the search field below of the window;
  • set memory size and CPUs;
  • set the size of the disk;
  • set the name of the VM and check on Customize configuration before install;
  • in the new window, select CPUs tab, expand Topology, select Manually set CPU topology and exchange the value of Sockets with the value of Cores;
  • click Apply and then Begin Installation on the top-left side of the window.