QEMU (on Windows)

Some notes and tips on how to build and run virtual machines (VMs) with the Quick Emulator (QEMU) on Windows.

Preparation

  1. Download and install QEMU ("QEMU is a generic and open source machine emulator and virtualizer").
  2. Performance tip for a Windows host: Activate the Windows Hypervisor Platform feature (called “whpx” in QEMU):
    1. Open PowerShell (as Administrator!)
    2. Run > Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All
    3. At the end, you will be asked to reboot the computer to apply the changes.

Create an empty disk image file for a VM

Use the program qemu-img (usually installed in C:\Program Files\qemu) with the command create to generate an empty disk image file (i.e. the “hard-disk” of the future VM).

Example (for a Haiku VM):

> qemu-img.exe create -f qcow2 C:\VMs\haiku.img 8G

Install an operating system to a VM

The program qemu-system-x86_64.exe (usually installed in C:\Program Files\qemu) is the main executable of QEMU for a x86-64-bit System running Windows: It provides the means to run a guest operating system on a Windows host.

Example: Install Haiku on a virtual x86-64-bit-PC as a guest for a Windows host

A virtual machine that represents a standard (x86-64-bit) PC and boots the Haiku ISO on boot from the “CD-ROM drive”.

For a Haiku VM (should all be on one line!):

> qemu-system-x86_64.exe -machine q35,usb=on
                         -cpu Penryn
                         -accel whpx
                         -drive file="C:\<path>\haiku.img",format=qcow2
                         -smp 4
                         -m 8G
                         -name Haiku
                         -usb
                         -device usb-tablet
                         -net user
                         -vga virtio
                         -display sdl
                         -cdrom "C:\<path>\haiku-...-anyboot.iso" # only needed for installation!
                         -boot menu=on                            # only needed for installation!

Optional:


Run the VM

After the OS is installed in the disk image file, run the same command as above (qemu-system-x86_64.exe -machine ...) to start the VM — but without the parameters for the boot medium (i.e. no -cdrom) and or boot order (i.e. no -boot)!

For daily use, it would make sense to either put it in a script or to use a GUI front-end for QEMU…


File Sharing between Guest and Host · 🚧 Not tested yet!

Example: Between Haiku (Guest) and Windows (Host)

SSH/SCP

SMB

But: Haiku/3rd-party-components only support SMBv1 — which is not secure and not recommended (thus disabled by default on Windows!).

On Windows:

  1. Share a directory (let’s call it “HaikuShare”)
  2. Enable/Disable SMB1
  3. Reboot

On Haiku:

  1. Create a local directory as the mount-point for the share: (let’s call it “WindowsShare”): mkdir /boot/home/Desktop/WindowsShare
  2. Mount the share: mount_smbfs //<Username>:<Password>@<IPAddressOfTheWindowsPC>/HaikuShare /boot/home/Desktop/WindowsShare

NFS

But: Windows 11 Pro doesn’t offer a NFS Server, only a NFS Client (and and Administrative Tools)
The Server for NFS is only available in Windows Server and Windows 11 Enterprise | Education editions (when the optional NFS Server capability is added via DISM; and even then, it’s limited).
— Source
Alternative: Use a NAS that offers NFS support

I would recommend NFS as SMB v1 is not secured:

Synology NAS do indeed have NFS support. In addition to enabling the protocol in settings, you may have to set NFS permissions on your shared folders in DSM (go to System Settings, then Shared Folders, select one and click Edit, then you have an NFS-Permissions tab). As already hinted at, never enable SMB v1 on any device, as the encryption of the SMB v1 protocol has been broken a long time ago and your devices will be wide open for ransomware and other attacks.

[…]

So after enabling NFS on my NAS, is there something I need to install on the Haiku side to be able to mount the network share?

Create a folder to receive your shared folder and connect to it via command line :

  mount_nfs NAS_address:/volume1/shared/folder /boot/home/nfs 0 0