help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debug grub scripts without rebooting into grub shell.


From: Glenn Washburn
Subject: Re: Debug grub scripts without rebooting into grub shell.
Date: Tue, 11 Jul 2023 16:26:32 -0500

On Sat, 8 Jul 2023 19:58:29 +0800
Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> Hi here,
> 
> Are there some convenient methods to debug grub scripts without
> rebooting into grub shell?

I would recommend running the GRUB EFI application in QEMU, as it will act
more closely to when running on bare metal. Here's an example of a QEMU
command that I use when doing development:

qemu-system-x86_64 -name '[x86_64-efi] Test Grub' \
 -m 2048 -bios OVMF.fd --enable-kvm -boot once=c,menu=on \
 -nodefaults -rtc base=localtime -vga std -snapshot \
 -drive file=/home/grub-tester/bootloader/efidisk.img,format=raw \
 -device virtio-scsi-pci,id=scsi0,num_queues=4 \
 -device scsi-hd,drive=drive0,id=systema,bus=scsi0.0,scsi-id=0,lun=0,channel=0 
\ 
 -drive file=/dev/sdc,format=raw,if=none,id=drive0,readonly=on \
 -device scsi-hd,drive=drive1,id=systemb,bus=scsi0.0,scsi-id=0,lun=1,channel=0 \
 -drive file=/home/user/disk.img,format=raw,if=none,id=drive1,readonly=on

If you want to use a block device, then you'll need to run as root or
otherwise have correct permissions to read from the device. But you can have 
everything in a disk image file and not need to run as root.

Also You can add the options "--nographic -serial stdio" to have the interface
be via serial, which allows text selection. In this case GRUB will need to be
configured to output to serial.

Glenn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]