QEMU: Difference between revisions

From NixOS Wiki
imported>Rti
(Created page with "A generic and open source machine emulator and virtualizer == Install == environment = { systemPackages = [ pkgs.qemu ]; }; == Booting UEFI == To boot UEFI systems us...")
 
m (link to qemu added)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
A generic and open source machine emulator and virtualizer
[https://www.qemu.org/ QEMU] is a generic and open source machine emulator and virtualizer.


== Install ==
== Install ==
environment = {
 
<syntaxhighlight lang=nix>
  environment = {
     systemPackages = [ pkgs.qemu ];
     systemPackages = [ pkgs.qemu ];
   };
   };
</syntaxhighlight>
=== Quick EMU ===
Quickly create and run highly optimised desktop virtual machines for Linux, macOS and Windows; with just two commands.
https://github.com/quickemu-project/quickemu
<syntaxhighlight lang=bash>
quickget windows 11
quickemu --vm windows-11.conf
</syntaxhighlight>


== Booting UEFI ==
== Booting UEFI ==
To boot UEFI systems using qemu, the UEFI firmware replacing the BIOS implementation needs to be provided while starting QEMU.
To boot UEFI systems using QEMU, the UEFI firmware replacing the BIOS implementation needs to be provided while starting QEMU.


The following installs a script, that always starts QEMU with OVMF firmware implementing UEFI support.
The following installs a script, that always starts QEMU with OVMF firmware implementing UEFI support.
<syntaxhighlight lang=nix>
  environment = {
  environment = {
   (pkgs.writeShellScriptBin "qemu-system-x86_64-uefi" ''
   systemPackages = [
    qemu-system-x86_64 \
    (pkgs.writeShellScriptBin "qemu-system-x86_64-uefi" ''
      -bios ${pkgs.OVMF.fd}/FV/OVMF.fd \
      qemu-system-x86_64 \
      "$@"
        -bios ${pkgs.OVMF.fd}/FV/OVMF.fd \
  '')
        "$@"
    '')
  ];
  };
  };
</syntaxhighlight>
qcow-efi images generated from [https://github.com/nix-community/nixos-generators nixos-generators] require more RAM than the default 128MB.  Failing to provide enough RAM results in grub reporting "error: start_image() returned 0x800000000000009." or systemd-boot reporting "Failed to execute NixOS: Out of resources".
[[Category:Virtualization]]

Latest revision as of 18:11, 18 June 2024

QEMU is a generic and open source machine emulator and virtualizer.

Install

  environment = {
    systemPackages = [ pkgs.qemu ];
  };

Quick EMU

Quickly create and run highly optimised desktop virtual machines for Linux, macOS and Windows; with just two commands.

https://github.com/quickemu-project/quickemu

quickget windows 11
quickemu --vm windows-11.conf

Booting UEFI

To boot UEFI systems using QEMU, the UEFI firmware replacing the BIOS implementation needs to be provided while starting QEMU.

The following installs a script, that always starts QEMU with OVMF firmware implementing UEFI support.

 environment = {
   systemPackages = [
     (pkgs.writeShellScriptBin "qemu-system-x86_64-uefi" ''
       qemu-system-x86_64 \
         -bios ${pkgs.OVMF.fd}/FV/OVMF.fd \
         "$@"
     '')
   ];
 };

qcow-efi images generated from nixos-generators require more RAM than the default 128MB. Failing to provide enough RAM results in grub reporting "error: start_image() returned 0x800000000000009." or systemd-boot reporting "Failed to execute NixOS: Out of resources".