Subject: bug#66207: Cannot boot VMs with grub-efi-bootloader

From: Ricardo Wurmus <[email-masked]>
Date: Sat, 30 Sep 2023 22:39:41 +0200

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> Ricardo Wurmus <[email-masked]> skribis:
>
>> I’m trying to build a more recent VM image than 1.4.0.  The 1.4.0 qcow2
>> image that’s available for download on the Guix website boots fine, but
>> any image created with a current Guix cannot be booted.
>>
>> I’m on Guix commit be5bec47f7942a5e4d2a30eadd9a6fa4c715e88b.
>>
>> I ran
>>
>>     ./pre-inst-env guix system image -t qcow2 \
>>         doc/os-config-lightweight-desktop.texi
>>
>> to generate the VM image and then I used
>>
>>     qemu-system-x86_64 -enable-kvm \
>>                        -m 4096 -monitor stdio \
>>                        -drive file=/tmp/guixvm.qcow2,id=myhd \
>>                        -vnc :1
>>
>> and connected Remmina to :1.
>>
>> The fan spins up to top speed and I see “Booting from Hard Disk…” with
>> no progress whatsoever.
>
> There have been recent changes in this area:
>
>   6bd17a0806 image: Do not allow BIOS bootloader and GPT.
>   e5ed1712da image: Introduce the mbr-hybrid-raw image type.
>
> The latter changes the default image type.  Before that, there was:
>
>   d57cab7641 image: Add mbr-raw-image-type and use by default.
>
> I’m not sure if this could explain the problem.

It’s due to the bootloader.  This field from the bare bones template
works:

  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (targets '("/dev/sdX"))))

but this from the desktop template doesn’t:

  (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (targets '("/boot/efi"))))

The manual for “guix system” gives a somewhat complicated invocation
that I only found out about later:

          image=$(guix system image --image-type=qcow2 \
                  gnu/system/examples/lightweight-desktop.tmpl)
          cp $image /tmp/my-image.qcow2
          chmod +w /tmp/my-image.qcow2
          qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
                             -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin

I haven’t tried it yet, but I assume that providing this extra “-bios”
option would fix it.  It wasn’t necessary before, though, and I think
it’s an inconvenient complication when running Guix VMs.

Perhaps an example invocation of qemu-system-* could be added as a
comment to the templates?

-- 
Ricardo