To run GuixSD in a virtual machine (VM), one can either use the
pre-built GuixSD VM image distributed at
, or build their own virtual machine image using
vm-image (see Invoking guix system). The returned image is in
qcow2 format, which the QEMU emulator can
If you built your own image, you must copy it out of the store
(see The Store) and give yourself permission to write to the copy
before you can use it. When invoking QEMU, you must choose a system
emulator that is suitable for your hardware platform. Here is a minimal
QEMU invocation that will boot the result of
vm-image on x86_64 hardware:
$ qemu-system-x86_64 \ -net user -net nic,model=virtio \ -enable-kvm -m 256 /tmp/qemu-image
Here is what each of these options means:
This specifies the hardware platform to emulate. This should match the host.
Enable the unprivileged user-mode network stack. The guest OS can access the host but not vice versa. This is the simplest way to get the guest OS online.
You must create a network interface of a given model. If you do not
create a NIC, the boot will fail. Assuming your hardware platform is
x86_64, you can get a list of available NIC models by running
qemu-system-x86_64 -net nic,model=help.
If your system has hardware virtualization extensions, enabling the virtual machine support (KVM) of the Linux kernel will make things run faster.
RAM available to the guest OS, in mebibytes. Defaults to 128 MiB, which may be insufficient for some operations.
The file name of the qcow2 image.
run-vm.sh script that is returned by an invocation of
guix system vm does not add a
-net user flag by default.
To get network access from within the vm add the
to your system definition and start the VM using
`guix system vm config.scm` -net user. An important caveat of using
-net user for networking is that
ping will not work, because
it uses the ICMP protocol. You’ll have to use a different command to check for
network connectivity, for example
To enable SSH inside a VM you need to add a SSH server like
(lsh-service) to your VM. The
(lsh-service) doesn’t currently
boot unsupervised. It requires you to type some characters to initialize the
randomness generator. In addition you need to forward the SSH port, 22 by
default, to the host. You can do this with
`guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
To connect to the VM you can run
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
ssh the port you want to connect to.
-o UserKnownHostsFile=/dev/null prevents
ssh from complaining
every time you modify your
config.scm file and the
-o StrictHostKeyChecking=no prevents you from having to allow a
connection to an unknown host every time you connect.
As an alternative to the default
qemu graphical client you can
remote-viewer from the
virt-viewer package. To
connect pass the
-spice port=5930,disable-ticketing flag to
qemu. See previous section for further information on how to do this.
Spice also allows you to do some nice stuff like share your clipboard with your
VM. To enable that you’ll also have to pass the following flags to
-device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5 -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent, name=com.redhat.spice.0
You’ll also need to add the see Spice service.