[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 14:45:36 +0800 |
On Wed, Jul 12, 2023 at 2:23 PM Glenn Washburn
<development@efficientek.com> wrote:
>
> On Wed, 12 Jul 2023 09:27:59 +0800
> Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> > On Wed, Jul 12, 2023 at 5:08 AM Glenn Washburn
> > <development@efficientek.com> wrote:
> > >
> > > On Sun, 9 Jul 2023 08:13:40 +0300
> > > Andrei Borzenkov <arvidjaar@gmail.com> wrote:
> > >
> > > > On 09.07.2023 03:21, Hongyi Zhao wrote:
> > > > > On Sat, Jul 8, 2023 at 9:53 PM Andrei Borzenkov <arvidjaar@gmail.com>
> > > > > wrote:
> > > > >>
> > > > >> On 08.07.2023 14:58, Hongyi Zhao wrote:
> > > > >>> Hi here,
> > > > >>>
> > > > >>> Are there some convenient methods to debug grub scripts without
> > > > >>> rebooting into grub shell?
> > > > >>>
> > > > >>
> > > > >> You may try grub-emu which emulates grub.
> > > > >
> > > > > I tried, but it seems that grub-emu doesn't meet my requirement as
> > > > > described below.
> > > > >
> > > > > I want to debug the grubx64.efi created by the following command:
> > > > >
> > > >
> > > > If you want to debug grubx64.efi, then you of course need to load it
> > > > either on real hardware or in VM. But you can debug scripts used by
> > > > grubx64.efi using grub-emu by setting up suitable simulated environment.
> > > > There are clear limitations (scripts cannot load and start any kernel).
> > >
> > > Point of clarification. If I'm not mistaken, grub emu can now indirectly
> > > load and start a kernel via kexec.
> >
> > What's the concrete steps?
>
> I've never used it, so I can't really say. Here's the patch[1] that got
> commited, but there have been further changes. Looks like there's a -X
> or --kexec option to grub-emu.
Maybe my version is too old, so I cannot see this option:
werner@X10DAi:~$ grub-emu -V
grub-emu (GRUB) 2.06-2ubuntu12.1
werner@X10DAi:~$ grub-emu --help
Usage: grub-emu [OPTION...]
GRUB emulator.
-d, --directory=DIR use GRUB files in the directory DIR
[default=/boot/grub]
-H, --hold[=SECS] wait until a debugger will attach
-m, --device-map=FILE use FILE as the device map
[default=/boot/grub/device.map]
--memdisk=FILE use FILE as memdisk
-r, --root=DEVICE_NAME Set root device.
-v, --verbose print verbose messages.
-?, --help give this help list
--usage give a short usage message
-V, --version print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Report bugs to <bug-grub@gnu.org>.
> If used once, it will use systemctl to
> do the kexec. If used twice, it will do the kexec itself. If you're not
> familiar with kexec, read about it before trying it. If successful, it
> will reboot your system, which I believe is not what you want.
Yes. BTW, the *reboot* behavior is what you indicated by *indirectly*
as you described previously:
> > > Point of clarification. If I'm not mistaken, grub emu can now indirectly
> > > load and start a kernel via kexec.
Best,
Zhao
> [1] https://mail.gnu.org/archive/html/grub-devel/2022-08/msg00284.html
>
> > > Glenn
> >
> > Zhao
> >
> > > > > $ grub-mkstandalone -O x86_64-efi -o grubx64.efi --modules='lvm fat
> > > > > ntfs part_msdos part_gpt ext2 btrfs probe regexp search configfile'
> > > > > boot/grub/grub.cfg=./grub.cfg
> > > > >
> > > > > The content of the ./grub.cfg is as follows:
> > > > >
> > > > > $ egrep -v '^[ ]*(#|$)' grub.cfg
> > > > > regexp -s __cmdpath_efi '^\(([^,]+)' "$cmdpath"
> > > > > export __cmdpath_efi
> > > > > for file in ($__cmdpath_efi,*)/multibootusb.git/grub.cfg; do
> > > > > if regexp -s __root '^(\([^*]+\))' "$file"; then
> > > > > set __prefix=$__root/multibootusb.git
> > > > > export __root
> > > > > export __prefix
> > > > > configfile $__prefix/grub.cfg
> > > > > break
> > > > > fi
> > > > > done
> > > > >
> > > > > The files' layout is as follows:
> > > > >
> > > > > $ tree .
> > > > > .
> > > > > ├── grub.cfg
> > > > > ├── grub-mkstandalone.sh
> > > > > ├── grubx64.efi
> > > > > └── iso
> > > > > ├── deepin-desktop-community-23-Beta-amd64.iso
> > > > > ├── rescatux-0.74.iso
> > > > > ├── supergrub2-2.06s1-beta2-multiarch-CD.iso
> > > > > ├── systemrescue-10.01-amd64.iso
> > > > > ├── ubuntu-23.04-desktop-amd64.iso
> > > > > └── ubuntukylin-23.04-desktop-amd64.iso
> > > > >
> > > > > 1 directory, 9 files
> > > > >
> > > > > Regards,
> > > > > Zhao
> > > >
- Re: Debug grub scripts without rebooting into grub shell., (continued)
- Re: Debug grub scripts without rebooting into grub shell., Andrei Borzenkov, 2023/07/09
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/09
- Re: Debug grub scripts without rebooting into grub shell., Andrei Borzenkov, 2023/07/09
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/09
- Re: Debug grub scripts without rebooting into grub shell., Andrei Borzenkov, 2023/07/09
- Re: Debug grub scripts without rebooting into grub shell., Hongyi Zhao, 2023/07/09
- 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, 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 <=
- 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, 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/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