• Guide

Notes about using virtualization technologies on Guix.



Read more about qemu.

Run as live machine

Let’s say you wanted to run PantherX Desktop in a virtual machine.

Create a system config px-desktop-config_vm.scm:

;; PantherX OS Desktop Configuration v2
;; for Virtual machine

(use-modules (gnu)
             (gnu system)
             (px system config))

  (host-name "px-base")
  (timezone "Europe/Berlin")
  (locale "en_US.utf8")

  (bootloader (bootloader-configuration
              (bootloader grub-bootloader)
              (target "/dev/vda")
              (terminal-outputs '(console))))
 (file-systems (cons (file-system
                      (mount-point "/")
                      (device "/dev/vda1")
                      (type "ext4"))

  (users (cons (user-account
                (name "panther")
                (comment "panther's account")
                (group "users")
                ;; Set the default password to 'pantherx'
                ;; Important: Change with 'passwd panther' after first login
                (password (crypt "pantherx" "$6$abc"))

                (supplementary-groups '("wheel"
                                        "audio" "video"))
                (home-directory "/home/panther"))

  ;; Globally-installed packages.
  (packages (cons*

  ;; Globally-activated services.
  (services (cons*

Build a VM from px-desktop-config_vm.scm:

guix system vm guix-desktop-vm_image.scm --substitute-urls=''

Once that’s done, you should get a bash script:

building /gnu/store/v6s7975lv0z95ss2k7bjc5y5j9myh4ap-copy-image.drv...
building /gnu/store/

Run like this:

/gnu/store/ -m 2048 -smp 2 -nic user,model=virtio-net-pci -enable-kvm


  • m is memory
  • smp is the processor count
  • enable-kvm will enable hardware acceleration (you should! enable this)

Important: To actually use the -enable-kvm flag, you need to enable it for your user, in the system configuration at /etc/system.scm. Learn more: More performance using KVM

Login with password pantherx.

Prepare permanent disk image

alternatively we can generate a disk image in QCOW2 format, containing Guix instance installed on match with our provided configuration file.

$ guix system vm-image /path/to/config.scm

later we can run this image using qemu.

$ qemu-system-x86_64 \
    -nic user,model=virtio-net-pci \
    -enable-kvm -m 1024 \
    -device virtio-blk,drive=myhd \
    -drive if=none,file=/path/to/...-qemu-image,id=myhd

Notes about running VM

running the disk image there are a series of items that we need to consider:

(1) generated disk image will be saved in store, and since store is a read-only location, we need to copy that to some other place and assign write permission before we can use generated image.

(2) default image generated using guix system vm-image usually doesn’t have enough space for additional files and packages to store/install. so if we need more space, we should pass our desired size using --image-size parameter.

$ guix system vm-image /path/to/config.scm --image-size=10G

(3) in order to have ssh access to the virtual machine, we need to forward default ssh port of the guest machine to some other port in host using hostfwt parameter of QEMU:

$ qemu-system-x86_64 -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22 ...

(4) later we can connect to guest machine using ssh client:

$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 root@

Useful QEMU tricks

switch VTERM on guest OS

in order to switch to other virtual TTY in guest os, we need to switch to monitoring console of QEMU using ctrl+alt+2 and send our key combination using sendkey command:

sendkey ctrl-alt-f2

later we can switch back to default console using ctrl+alt+1 command.

See also

PantherX & (unofficial) GNU Guix Wiki.

Last update: 2024-04-21 10:28:03 +0000 | Apache-2.0

Inspired by the excellent Arch Linux Wiki