The most convenient way of using an hypervisor on Linux is probably running Windows on it, since the lack of device drivers can still be considered as the achilles heel of Linux, and there still exist a plethora of sectoral software which only run on MS Windows. For all the people using dual booting (having installed Easy either on HDD-partion or external USB stick) this makes it also obviously possible to use Windows without having to reboot the physical machine every single time.
1) Needed data / preparation:
In order to install a Windows virtual machine (VM from now on) on Easy, you'll obviously first need a Windows 10 installation media. We need an ISO file containing the whole installation image. If you have a Windows 10 physical installation DVD at your disposal, it is possible to extract the corresponding image from it and save it onto an ISO file by using free software like ImgBurn et similia. If not, you can download the Windows 10 Media Creation Tool from the Microsoft website and download the latest X86-64 build of Windows 10 through it. In this latter case, please arm yourself with patience, since the download won't work on Linux (you need to access the download page from MS Windows and obviously the program itself only runs on Windows). The way you want to go is up to you; also up to you is the version of Windows 10 which you install. Please keep in mind that the OS has been around for a while now (since July 2015) and that earlyer versions tend to be smaller in size, but obviously also less secure. Regarding the disk space needed you can calculate about 5 GB for the ISO file, but it is possible to delete it after the installation or to store it outside of Easy; and a minimum of 11 GB of space on the Easy partition for the Windows virtual HDD file are needed.
We also need another ISO file named "virtio-win-0.1.229.iso" which is about 500 MB in size and can be downloaded from here.
This file contains important Windows device drivers for QEmu virtual devices. Once you've finished downloading please move both files to a location accessible by Easy. Any location can be used, provided that it is accessible by Easy. In this guide we will assume that all data has been placed into /files/other .
Your CPU should support the Intel Virtualization Technology or AMD-Virtualization for AMD. So please check in the BIOS that these features are present and active (they are usually active by default).
CPUs without these features should be the vast minority nowadays.
In case you are not sure if your hardware and / or operating system kernel are overall capable of running QEmu, you can download and run the QEmu-ready package from here. Just extract it somewhere and run it and you should see something like this (if you are on Intel):
2) Installation:
in order to run QEmu on Easy, you'll obviously need to install it. Please run PKGget and install the package qemu-6.2.0-r5 if you are using EasyOS Kirkstone or qemu-8.2.1-r1 if you are using EasyOS Scarthgap. Keep in mind that normally the package isn't installed, even if it is shown as being installed (so click on it to install it).
The old version of it (6.2.0-r4) lacks important functionalities. Therefore, if PKGget does not show the latest version, either update the repository (configure packet manager button --> update now) or just update Easy to the latest version. The correct procedure for the installation is to update the packages database by pressing the Configure package manager button and update database --> update now. Afterwards, when installing the QEmu package PKGget should automatically ask if to also download and install all its required dependencies (which should be particular versions of virglrenderer and libvulkan). Let PKGget download and install them. Please do not install any foreign package for any reason.
To check if the software has been installed and works correctly you can issue the command:
Code: Select all
qemu-system-x86_64 --help
this should show the complete list of possible options and values for the program.
To ascertain which version of the software is installed and being used:
Code: Select all
# qemu-system-x86_64 --version
QEMU emulator version 8.2.1
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers
#
It is also adviceable to do the following:
Code: Select all
export QEMU_AUDIO_DRV=pa
this adds the environment variable "QEMU_AUDIO_DRV" with value "pa" to the system.
3) Configuration:
first of all we will have to create the file which will act as the virtual system drive for our VM. This file will grow dynamically in size. Meaning that it will be just a few kilobytes big at the beginning and will be allowed to grow on demand till the size we want to allow. I assume that 20 GB are enough. Otherwise, adjust the command as needed:
Code: Select all
# cd /files/other
# qemu-img create -f qcow2 winvirtualdisk.qcow2 20G
you can also name the qcow2 file as you wish. This is just an example. In case you want your virtual system drive file to grow beyond the limit you had set in the past (let's say from 20 to 50 GB), you can simply use the following command:
Code: Select all
# cd /files/other
# qemu-img resize winvirtualdisk.qcow2 50G
Image resized.
#
and, of course, the partition will need to be manually expanded afterwards (you can go to Control Panel --> Computer Management --> Disk Management or use any other partition resizing utility).
Once the file has been created and placed on the same folder where the windows ISO and virtio-win-0.1.229.iso are located, we can go on and start our VM for the first time:
For QEmu 6 on EasyOS Kirkstone:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-boot d \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audiodev pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host \
-cdrom [Windows 10 ISO filename].ISO
For QEmu 8 on EasyOS Scarthgap:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 2 \
-hda [virtual disk filename].qcow2 \
-boot d \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audio pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host \
-cdrom [Windows 10 ISO filename].ISO
let's comment this long command as far as possible:
qemu-system-x86_64 --> we are emulating an x86_64 machine.
-enable-kvm --> this enables the kvm accelerator.
-m 4G --> we assign 4 GB of RAM memory to this VM. We have tested that Windows 10 does not run well enough when it's only given 2 GB of RAM. Hence, it is unfortunately not advisable to do this on PCs which only have 4 Gigs, since one should never assign more than 50% of the available physical memory to a VM generally speaking. Obviously if you have
16 GB of RAM, assigning 6 of them to this virtual machine will be a much better choice.
-smp 4 --> with this we say to QEmu that we want to emulate an x86_64 CPU, with 4 threads. Windows 10 seems to be barely usable with just 2 QEmu threads. Obviously it's much better to assign 6 threads, but it's only advisable on physical machines equipped with at least an 8 cores / 16 threads physical CPU.
-boot d --> with this we say to QEmu that we want to start the system from the virtual DVD-ROM drive, and not from the virtual HDD.
-net nic,model=virtio --> we want to emulate a "virtio" network card. That's because we (should) already have the needed drivers for it.
-vga virtio --> we want to emulate a "virtio" video card. That's because we (should) already have the needed drivers for it.
-device ich9-intel-hda,id=sound0
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0
-audiodev pa,id=hda,server=[pulse audio server string] // or "-audio pa,id=hda,server=[pulse audio server string]" for QEmu 8
-global ICH9-LPC.disable_s3=1
-global ICH9-LPC.disable_s4=1
all these 5 lines are just needed to configure the virtual audio card in such a way that it can be digested and used by Windows 10.
-rtc base=localtime,clock=host --> this will sync the clock with the time of the host.
The pulse audio server string can be retrieved by issueing the command:
Code: Select all
pactl info
it should be /run/pulse/native --> (but I cannot be sure that it's identical on every version of Easy)
-cdrom [Windows 10 ISO filename].ISO --> we just say that the Windows 10 ISO image file we just downloaded should act as a physical DVD which is inserted into our virtual DVD-ROM drive.
Now theoretically the VM should be running and you should be going through the usual Windows 10 installation process. It's up to you if you want to add a license Key to your new system. If you don't have any, you can obviously just click on the link I don't have a produkt key to skip the process.
When the installation procedure finishes, Windows 10 should boot with standard drivers. Audio should already work and internet also. Please don't worry if the image quality isn't that good at the moment. Just power-off the system. Now the virtual HDD file should have grown in size till about 11 GBs. You can start your Windows 10 VM again by issueing (and re-issueing when needed) the command:
For QEmu 6 on EasyOS Kirkstone:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audiodev pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host
For QEmu 8 on EasyOS Scarthgap:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audio pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host
you can direct your input back to the host with the key combination Ctrl + Alt + G
4) Finishing touches:
Video and network drivers:
For adding correct video and network drivers, we will have to use the second iso file containing drivers, which you should have downloaded at the beginning of this article.
QEmu should be started in the following way:
For QEmu 6 on EasyOS Kirkstone:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audiodev pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host \
-cdrom virtio-win-0.1.229.iso
For QEmu 8 on EasyOS Scarthgap:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audio pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host \
-cdrom virtio-win-0.1.229.iso
when the system boots up you should find on Explorer a disk inserted into the virtual DVD-Rom drive. This disk contains all the drivers for any virtual QEmu device. So there will be many folders and 2 executables on it. Execute the 64 bit executable in order to run the software. If you follow the wizard, it should install automatically all the needed drivers, as well as create the C:\Program Files\Virtio-Win folder, containing all the virtio drivers for your system. If the automatic Wizard doesn't work for any reason, the correct driver for the network card is inside C:\Program Files\Virtio-Win\Network ; and the one for the video-card inside C:\Program Files\Virtio-Win\Viogpudo . After installing these drivers the video quality should be much better and also Internet surfing should be much faster (as fast as on the host).
After you've done this, there will be no more need to execute QEmu with the option -cdrom virtio-win-0.1.229.iso . The line can be removed.
Run Windows 10 in a maximized QEmu Window:
As far as I know, QEmu does not support fullscreen mode. What one can do is to maximize its window for using the emulated system with the highest possible resolution. There are still unfortunately minor issues when selecting the same resolution of the host.
For example, if you a have a full HD screen (1920 x 1080 pixel), when you select 1920 x 1080 on the Windows 10 advanced screen settings, QEmu will shrink the image (because obviously its window is always smaller than 1920 x 1080 pixel) and 2 black stripes will appear on the left and right sides of the screen; furtherly, the image will be quite blurry, making it difficult to read text, especially on smaller screens. Now: for some reason, if you restart the emulated system, the image will be corrected and QEmu will automatically instruct Windows 10 to use the modified resolution which best fits the size of the window. Please take notice of this resolution. If you have a full HD screen, it will be most probably 1910 x 1011 pixels.
It is for sure not comfortable to have to start the system and restart it once every time, just to have a correct video image.
So, this problem can also be solved by using the CRU software (Custom Resolution Utility) which can be downloaded here.
- Run CRU
- On the upper window labeled Detailed resolutions click the Add button.
- Even if it is already listed, add the resolution you have taken notice of previously, so specify the number of horizontal and vertical lines (and select an appropriate refresh rate for your screen)
- Click OK, your custom resolution will be added to the list.
- Click the button with the arrow upwards to move your newly created custom resolution to the top.
- Now click OK.
Now, the next time the system starts, you will be able to have your custom resolution loaded, which perfectly fills the screen, by just executing the file restart64.exe, which is located inside the CRU folder.
Connecting USB devices from the host to the guest:
It is possible to passthrough to the guest any USB device connected to the host. There are several ways to do that. First of all the lsusb command should be issued:
Code: Select all
lsusb
the output of the lsusb command shows every device connected to the host. Every device is connected to a particular USB bus and is allocated to a particular bus address. More over, every device has a particular vendorid and a particular productid. The vendorid is represented by the 4 digits before the colon, whilst the productid is represented by the 4 digits after the colon.
Now: if the VM is not running we can add lines like these to the QEmu startup command:
Code: Select all
-device usb-host,hostbus=3,hostaddr=3
or:
Code: Select all
-device usb-host,vendorid=0x6ade,productid=0x9582
so that the VM starts with the needed device(s) already attached. If using lines like the first one, for the same USB device the needed command may change every time the device is physically connected to the host. This is due to the fact that USB devices are dynamically allocated to buses and addresses. Therefore, it is better to use vendor and product ids, like in the second line, so that the command never chnges for a given device.
It is even possible to passthrough USB devices on the fly, when the virtual machine is already runnning. To do that, just select the QEmu window and type the key-combination Ctrl + Alt + 2 . This should call the QEmu console, which is called Monitor. Here it is possible to directly type commands for interacting with the VM.
For connecting a USB device, of which the bus number and address are known, just type, for example:
Code: Select all
device_add usb-host,hostbus=2,hostaddr=3
and hit Enter.
To connect a USB device, of which you know vendor and product IDs, just type for example:
Code: Select all
device_add usb-host,vendorid=0x6ade,productid=0x9582
and hit Enter.
Sharing a folder with the host:
This is also doable in a relatively easy way. Please notice that there will be anyway no network connection between host and guest. Only the desired folder will be shared.
First of all we need to create a samba share on our Easy host. To do that select Menu --> Network and launch EasyShare. Please if you havn't already done so, click the Samba Setup button and setup the Samba daemon correctly. The writing under the Samba Setup button should be green and should say that the Samba daemon is running. Now in the Samba Setup section it is possible to setup network shares with paths and share names; please share at least one folder. Inside the lower Shared local folders section the shared folder should appear. It's absolutely up to you which folder to share. Notice that this folder will also be accessible by any other PC connected to your own network.
When you are ready, you should start QEmu with the following command:
For QEmu 6 on EasyOS Kirkstone:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user,smb=[absolute path to the smb share] \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audiodev pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host
For QEmu 8 on EasyOS Scarthgap:
Code: Select all
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 4 \
-hda [virtual disk filename].qcow2 \
-net nic,model=virtio \
-net user,smb=[absolute path to the smb share] \
-vga virtio \
-device ich9-intel-hda,id=sound0 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-audio pa,id=hda,server=[pulse audio server string] \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \
-rtc base=localtime,clock=host
please pay attention to the fact that the [absolute path to the smb share] is not the Samba share name, but just the absolute path to the shared folder.
For example: if you have shared the folder /files/other/qemushare with name qemushare, you will have to use the following line:
Code: Select all
-net user,smb=/files/other/qemushare
regardless of the fact that other PCs connected to your network may access your share just by going to the path \\[your IP address]\qemushare .
When the VM boots up, just open up Windows Explorer and on the menu bar click on "Computer" and then on the button labeled connect network drive. Inside the resulting dialogue window, just choose a drive letter and type the following inside the Folder field:
Code: Select all
\\10.0.2.4\qemu
Hit the finish button and you should be already good to go. You will directly find the shared folder everytime you open up Windows Explorer.
Making easyer to start the VM:
This is obvious. I just add this for completeness. To launch the VM easyer one can create a shell script and place it anywhere, containg the launch command. On the -hda line it is also possible to specify the absolute path to the virtual HDD file, so that the VM can be launched from anywhere. Once this shell script exists somewhere, one can place a new link on the desktop calling it.
Inside the breeze and breeze-dark icon themes even Windows icons can be found, for example image-vnd.microsoft.icon.svg .
Retrieving free space from the virtual drive file:
As already explained, the virtual drive file will grow on demand till the maximum allowed size. If for any reason the space occupation gets smaller on the virtual drive, the file will not be shrinked accordingly.
The procedure to manually shrink the file and retrieve the free space on the host is as follows:
launch the VM, go to this website, download the tool Sdelete and extract the zip file contents somewhere.
with an elevated shell go to the location where you extracted the files and execute:
Code: Select all
sdelete64 -z
accept the license conditions and wait till the operation finishes.
power off the VM.
on the host cd to the folder where the drive file is located:
Code: Select all
cd /files/other
- create a new shrinked drive file:
Code: Select all
qemu-img convert -O qcow2 winvirtualdisk.qcow2 new_winvirtualdisk.qcow2
In this way a new image file will be created and it will be as small as possible for containing the given VM. Please pay attention to the fact that the host file system must have enough free space for containing the new VM drive file. When the process finishes, the old file may be deleted and the new one renamed as needed.
Optional Windows 10 optimizations:
These optimizations are aimed to reduce the average load on the CPU and system drive.
1) Stop the automatic installation of Microsoft Edge --> launch Regedit and open [HKEY LOCAL MACHINE]>[SOFTWARE]>[MICROSOFT]. Here please create a new registry key and name it EdgeUpdate. Inside this newly created key, create a new DWORD value (32 bit) and name it DoNotUpdateToEdgeWithChromium. Assign to this newly created dword the value 1. Restart the system once.
2) Disable the automatic drive defragmentation service --> go to Defragment and Optimize Drives either by opening the Start menu and typing defrag or by going to the Control Panel > Computer Management; here select your system drive and press the Change Settings button. Uncheck the Run on a schedule button and click OK. Restart the system.
3) Disable the Windows Search service --> do either right mouse click on the Start menu > Run or press the key combination Windows key + R. Here type services.msc and click OK. On the list of services which opens up, search for the Windows Search service (its name should be language independent and should be located towards the bottom of the list). When you've found it, select it and right mouse click > Stop. Then do right mouse click > Properties. On the drop down menu named Startup type choose the option Disabled and click OK. Restart the system.
4) If you don't use Windows Firewall, get rid of the Windows Firewall notification --> this may change according to the version of Windows 10. Go here and follow Microsoft's guidelines. Basically, you just need to go to Activate / deactivate notifications and de-select the Network-Firewall option.