[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Debug grub scripts without rebooting into grub shell.
From: |
Hongyi Zhao |
Subject: |
Re: Debug grub scripts without rebooting into grub shell. |
Date: |
Wed, 12 Jul 2023 09:25:15 +0800 |
On Wed, Jul 12, 2023 at 5:26 AM Glenn Washburn
<development@efficientek.com> wrote:
>
> 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.
I tried to adapt your approach to my case, but it didn't work:
werner@X10DAi:/media/werner/a5d0e46f-aea7-43f0-9a3e-cfb6d517d214/EFI/grub-mkstandalone$
sudo 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=./grubx64.efi,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
format=raw,if=none,id=drive1,readonly=on
qemu-system-x86_64: -drive
file=/dev/sdc,format=raw,if=none,id=drive0,readonly=on: Could not open
'/dev/sdc': No such file or directory
> 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
Zhao
- Re: Debug grub scripts without rebooting into grub shell., (continued)
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/11
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/11
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/12
Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/09
Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/11
- Re: Debug grub scripts without rebooting into grub shell.,
Hongyi Zhao <=
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/12
- Re: Debug grub scripts without rebooting into grub shell., Glenn Washburn, 2023/07/12