Skip to content

Explain how to use an image generated by diskoImagesScript to run a VMΒ #1018

@zackw

Description

@zackw

https://github.com/nix-community/disko/blob/master/docs/disko-images.md says "The generated image can be used as a VM" but I cannot figure out how to actually run that VM. I tried several different qemu invocations, none of which worked:

  • qemu-kvm -smp cpus=2 -m 8192 -drive format=raw,file=image.raw: Hangs on the BIOS splash screen.
  • qemu-kvm -smp cpus=2 -m 8192 -nographic -no-reboot -device virtio-rng-pci -kernel /nix/store/fib81p2nafh85c19w245ki0fk3r3n93f-kernel-modules/bzImage -initrd /nix/store/5gg1q4v6cc1ws6fj8giy0x4pflbcflh1-initrd/initrd -append "console=ttyS0 panic=1" -drive if=pflash,format=raw,unit=0,readonly=on,file=/nix/store/5asi8v7c0lf9spwgg3nzm16mjhf3a93i-OVMF-202408.01-fd/FV/OVMF_CODE.fd -drive if=pflash,format=raw,unit=1,file=efi-vars.fd -drive file="$PWD"/image.raw,if=virtio,cache=unsafe,werror=report,format=raw and several other variations on this theme: "Kernel panic - not syncing: Attempted to kill init!" at some point during execution of the initrd.
  • qemu-kvm -smp cpus=2 -m 8192 -no-reboot -device virtio-rng-pci -virtfs local,path=/nix/store,security_model=none,mount_tag=store -virtfs local,path=$PWD,security_model=none,mount_tag=xchg -drive if=pflash,format=raw,unit=0,readonly=on,file=/nix/store/5asi8v7c0lf9spwgg3nzm16mjhf3a93i-OVMF-202408.01-fd/FV/OVMF_CODE.fd -drive if=pflash,format=raw,unit=1,file=efi-vars.fd -drive file="$PWD"/image.raw,if=virtio,cache=unsafe,werror=report,format=raw: Hangs inside the initrd, waiting for several different /dev/disk/by-partlabel/XXX entries to materialize. After 90 seconds systemd gives up and tries to drop into emergency mode, which doesn't work because the root account doesn't exist yet.

(All store paths in the above were extracted from the ./result script generated by a test derivation.)

Please document the procedure for running a VM from an image generated by the diskoImagesScript derivation.

If possible, document both how to run it in QEMU's default graphical mode and in -nographic mode.

If possible, document both how to run it with a /nix/store embedded in the image, and with one shared with the host (i.e. both possible settings of disko.imageBuilder.copyNixStore).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions