Mailing List Archive

Pygrub does not boot ext2 on LVM volume other than from root directory
Hi all,

I have a weired problem with pygrub.

The machine I am running xen is a PC-Engines APU for which I build xen
and tools using Yocto project. Version of Xen 4.16 stable from the
"Kirkstone" branch of Yocto.

Everything went well and I was able to install the image on a LVM
Volume. Hypervisor runs well. I created separate logical volumes for
DomU guests and installed Debian on it. I am also able to boot the DomU
guest as long as I copy the kernel and initrd.img to the Dom0
filesystem and use the "kernel=" parameter in the xen.cfg file.

When I try to use pygrub to boot the guest it tells that it does not
find a partition containing a kernel. With a little investigation I
found out, that it is not a parsing problem of grub.cfg but it does not
find grub.cfg at all.

So I compiled the libfsimage with debug information (-DE2DEBUG in
Makefile) and found out, that the libfsimage does not recurse into the
directories. It finds /boot at the root directory but does not recurse
into it while it looks for /boot/grub/grub.cfg.

When I mount the volume and filesystem directly using xl-attach
everthing is o.k. so the filesystem itself seems to be o.k.

I also created a dummy menu.lst file at root directory. Interestingly
pygrub the finds it, is able to parse it, shows the menu and then fails
when he tries to find the kernel because then he has to recurse into
/boot directory again.

Next test was, that i copied kernel and initrd directly into the root
directory and refered to a menu.lst also in root directory. Now pygrub
finds everything and starts the DomU.


Any ideas, what the problem is?


If it helps I copy the output of the Debug (E2DEBUG flag set):
>fsblock 8737 buffer c2ef0f40
>directory entry ino=23
>entry=libx32
>dirname=boot, rest=, loc=200
>ed 41 00 00 00 10 00 00 1a fe 97 65 1c fe 97 65
>1c fe 97 65 00 00 00 00 00 00 12 00 08 00 00 00
>00 00 08 00 44 01 00 00 0a f3 01 00 04 00 00 00
>00 00 00 00 00 00 00 00 01 00 00 00 21 22 00 00
>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>00 00 00 00 00 00 00 00 00 00 00 00 04 72 00 00
>logical block 0
>fs block=8737
>fsblock 8737 buffer c2ef0f40
>directory entry ino=8193
>entry=boot
>inode 8193
>dirname=/grub/grub.cfg
>ipg=8192, dpb=128
>group_id=1 group_desc=0 desc=1
>fsblock 1 buffer c2eeeec0
>gdp=c2eeeec0, inodes_per_block=16, inode_offset=0
>inode table fsblock=0
>fsblock 0 buffer c2eefec0
>ipb=16, sizeof(inode)=256
>inode=c2eefec0, raw_inode=c2eefec0
>offset into inode table block=0
>00 first word=0
>first word=0
>Bad filetype: Size:0, Mode:0, IsDir:0
>inode 2
>dirname=/grub/grub.cfg
>ipg=8192, dpb=128
>group_id=0 group_desc=0 desc=0

As one can see, it goes through the root directory. In the output I
deleted the beginning. On top of the trace it looks at INODE libx32 and
looking for an entry called "boot". That is correct so far. Next if
finds "boot". INODE number 8193 is also correct (checked with debugfs)
and tries to recurse down and look for /grub/grub.cfg.
But now something seems to go wrong. Instead of the next INODE it sees
only 00.


Any help is highly appreciated.

Regards Martin
AW: Pygrub does not boot ext2 on LVM volume other than from root directory [ In reply to ]
Hi!

Not sure if this is related to your problem. But we noticed that the boot partition must be the first one in the disk section:
root = '/dev/xvda2 ro'
disk = [
'phy:/dev/vg0/vm-disk,xvda2,w',
'phy:/dev/vg0/vm-swap,xvda1,w',
]

Regards
Klaus

> -----Ursprüngliche Nachricht-----
> Von: Xen-users <xen-users-bounces@lists.xenproject.org> Im Auftrag von
> Martin Lang
> Gesendet: Sonntag, 7. Januar 2024 10:17
> An: xen-users@lists.xenproject.org
> Betreff: Pygrub does not boot ext2 on LVM volume other than from root
> directory
>
> Hi all,
>
> I have a weired problem with pygrub.
>
> The machine I am running xen is a PC-Engines APU for which I build xen
> and tools using Yocto project. Version of Xen 4.16 stable from the
> "Kirkstone" branch of Yocto.
>
> Everything went well and I was able to install the image on a LVM
> Volume. Hypervisor runs well. I created separate logical volumes for
> DomU guests and installed Debian on it. I am also able to boot the DomU
> guest as long as I copy the kernel and initrd.img to the Dom0
> filesystem and use the "kernel=" parameter in the xen.cfg file.
>
> When I try to use pygrub to boot the guest it tells that it does not
> find a partition containing a kernel. With a little investigation I
> found out, that it is not a parsing problem of grub.cfg but it does not
> find grub.cfg at all.
>
> So I compiled the libfsimage with debug information (-DE2DEBUG in
> Makefile) and found out, that the libfsimage does not recurse into the
> directories. It finds /boot at the root directory but does not recurse
> into it while it looks for /boot/grub/grub.cfg.
>
> When I mount the volume and filesystem directly using xl-attach
> everthing is o.k. so the filesystem itself seems to be o.k.
>
> I also created a dummy menu.lst file at root directory. Interestingly
> pygrub the finds it, is able to parse it, shows the menu and then fails
> when he tries to find the kernel because then he has to recurse into
> /boot directory again.
>
> Next test was, that i copied kernel and initrd directly into the root
> directory and refered to a menu.lst also in root directory. Now pygrub
> finds everything and starts the DomU.
>
>
> Any ideas, what the problem is?
>
>
> If it helps I copy the output of the Debug (E2DEBUG flag set):
> >fsblock 8737 buffer c2ef0f40
> >directory entry ino=23
> >entry=libx32
> >dirname=boot, rest=, loc=200
> >ed 41 00 00 00 10 00 00 1a fe 97 65 1c fe 97 65
> >1c fe 97 65 00 00 00 00 00 00 12 00 08 00 00 00
> >00 00 08 00 44 01 00 00 0a f3 01 00 04 00 00 00
> >00 00 00 00 00 00 00 00 01 00 00 00 21 22 00 00
> >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> >00 00 00 00 00 00 00 00 00 00 00 00 04 72 00 00
> >logical block 0
> >fs block=8737
> >fsblock 8737 buffer c2ef0f40
> >directory entry ino=8193
> >entry=boot
> >inode 8193
> >dirname=/grub/grub.cfg
> >ipg=8192, dpb=128
> >group_id=1 group_desc=0 desc=1
> >fsblock 1 buffer c2eeeec0
> >gdp=c2eeeec0, inodes_per_block=16, inode_offset=0
> >inode table fsblock=0
> >fsblock 0 buffer c2eefec0
> >ipb=16, sizeof(inode)=256
> >inode=c2eefec0, raw_inode=c2eefec0
> >offset into inode table block=0
> >00 first word=0
> >first word=0
> >Bad filetype: Size:0, Mode:0, IsDir:0
> >inode 2
> >dirname=/grub/grub.cfg
> >ipg=8192, dpb=128
> >group_id=0 group_desc=0 desc=0
>
> As one can see, it goes through the root directory. In the output I
> deleted the beginning. On top of the trace it looks at INODE libx32 and
> looking for an entry called "boot". That is correct so far. Next if
> finds "boot". INODE number 8193 is also correct (checked with debugfs)
> and tries to recurse down and look for /grub/grub.cfg.
> But now something seems to go wrong. Instead of the next INODE it sees
> only 00.
>
>
> Any help is highly appreciated.
>
> Regards Martin