Discussion:
Chainloading isolinux.bin
4javier
2016-02-03 12:20:42 UTC
Permalink
Good morning.

Long story short:
Is it GRUB2 capable of chainloading directly an isolinux.bin file (sort of
stage2 for the iso bootloader of syslinux bootloaders project)?

P.S.
I know I can chainload unextracted iso directly by loopback device, but I'd
rather like be able to use original distro boot menu, with no need to
manipulate any config file.

Long explanation for bored people with some spare time:
I'm setting up a multiboot usb thumbdrive, just systemrescuecd and kali
linux at the moment. I installed GRUB2 on MBR and on a separate /boot
partition. Then I created two more partitions where I extracted the content
of the two iso distros. I didn't execute their persistent installation
scripts, beacuase I think that the only tasks they execute are unpacking
the iso and install a syslinux bootloader. Considering that the isos
themselves already ship an isolinux complete configuration (isolinux.bin,
isolinux.cfg, etc.) I'd like to chainload directly grub to that.

I tried
set root=(hd0,3) (partition where sysrescuecd has been extracted)
insmod chain
insmod iso9660 (needed? I don't think so, since iso has been extracted on
an ext4 partition)
chainloader /isolinux/isolinux.bin

I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Andrei Borzenkov
2016-02-03 13:51:48 UTC
Permalink
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
4javier
2016-02-03 14:29:28 UTC
Permalink
You're right. My fault thinking that "chainloader" command would have ran
directly the chained bootloader with no need of "boot" command. Anyway, I
just tried, and shell just shows a blinking cursor on a new line, doing
nothing.
Post by Andrei Borzenkov
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
Andrei Borzenkov
2016-02-03 14:39:19 UTC
Permalink
Post by 4javier
You're right. My fault thinking that "chainloader" command would have ran
directly the chained bootloader with no need of "boot" command. Anyway, I
just tried, and shell just shows a blinking cursor on a new line, doing
nothing.
Well ... chainloader command loads single sector. El Torito boot image
can be of arbitrary (withing some limits) length. As soon as
isolinux.bin exceeds 512 bytes, it's going to fail.

Second problem is whether isolinux.bin was built for specific memory
address and for which one (this information is present in El Torito
boot catalog and is missing here of course).

Third consideration is, block size on CD is 2048 bytes which does not
match what you have on HDD (either 512 or 4096). It will likely make
it impossible for isolinux.bin to read anything.
Post by 4javier
Post by Andrei Borzenkov
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
4javier
2016-02-03 19:23:37 UTC
Permalink
In effect I have the El Torito boot catalog in the same directory, and its
size is 2KB. But If I open it with an hex editor, it has just early byte
wrote, and about 90% of the rest is just filled with zeros. I think it's
due to blocksize. But I can't understand how it could be just 2KB when
blocksize of the partition is 4096. Shouldn't it be 4 KB?
Post by Andrei Borzenkov
Post by 4javier
You're right. My fault thinking that "chainloader" command would have ran
directly the chained bootloader with no need of "boot" command. Anyway, I
just tried, and shell just shows a blinking cursor on a new line, doing
nothing.
Well ... chainloader command loads single sector. El Torito boot image
can be of arbitrary (withing some limits) length. As soon as
isolinux.bin exceeds 512 bytes, it's going to fail.
Second problem is whether isolinux.bin was built for specific memory
address and for which one (this information is present in El Torito
boot catalog and is missing here of course).
Third consideration is, block size on CD is 2048 bytes which does not
match what you have on HDD (either 512 or 4096). It will likely make
it impossible for isolinux.bin to read anything.
Post by 4javier
Post by Andrei Borzenkov
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
4javier
2016-02-03 19:26:11 UTC
Permalink
Ok. Forget my last message. 2 KB was the actual dimension of the file, ls
shows that on my filesystem the file correctly takes 4 KB.

Back to topic, as far as I understand, there's no way to chainload isolinux
bootloader from grub. Some days ago I tried the procedure through loopback
device, with the same result. I think the created loop device is not
exactly an iso filesystem, right?

Thanks for your time and for the explanations..
Post by 4javier
In effect I have the El Torito boot catalog in the same directory, and its
size is 2KB. But If I open it with an hex editor, it has just early byte
wrote, and about 90% of the rest is just filled with zeros. I think it's
due to blocksize. But I can't understand how it could be just 2KB when
blocksize of the partition is 4096. Shouldn't it be 4 KB?
Post by Andrei Borzenkov
Post by 4javier
You're right. My fault thinking that "chainloader" command would have
ran
Post by 4javier
directly the chained bootloader with no need of "boot" command. Anyway,
I
Post by 4javier
just tried, and shell just shows a blinking cursor on a new line, doing
nothing.
Well ... chainloader command loads single sector. El Torito boot image
can be of arbitrary (withing some limits) length. As soon as
isolinux.bin exceeds 512 bytes, it's going to fail.
Second problem is whether isolinux.bin was built for specific memory
address and for which one (this information is present in El Torito
boot catalog and is missing here of course).
Third consideration is, block size on CD is 2048 bytes which does not
match what you have on HDD (either 512 or 4096). It will likely make
it impossible for isolinux.bin to read anything.
Post by 4javier
Post by Andrei Borzenkov
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
Andrei Borzenkov
2016-02-04 07:20:47 UTC
Permalink
Post by 4javier
Ok. Forget my last message. 2 KB was the actual dimension of the file, ls
shows that on my filesystem the file correctly takes 4 KB.
Back to topic, as far as I understand, there's no way to chainload isolinux
bootloader from grub. Some days ago I tried the procedure through loopback
device, with the same result. I think the created loop device is not exactly
an iso filesystem, right?
Created loop device is exactly what is in file it is created from. The
main problem is, once you leave GRUB this "device" is no more present.
You would need to implement something like syslinux memdisk to hook
into INT13 and emulate BIOS device. This is not impossible (GRUB
already has INT13 handler to implement partition remapping).

Secondary consideration remains - chanloader is not really suitable
for it. CD-ROM boot protocol is sufficiently different from standard
HDD handover. This again is not impossible, but someone will need to
implement it.

This would be interesting project for someone interested in GRUB
development, but if you are just interested in end result, memdisk +
sbm are probably easier.
Post by 4javier
Thanks for your time and for the explanations..
Post by 4javier
In effect I have the El Torito boot catalog in the same directory, and its
size is 2KB. But If I open it with an hex editor, it has just early byte
wrote, and about 90% of the rest is just filled with zeros. I think it's due
to blocksize. But I can't understand how it could be just 2KB when blocksize
of the partition is 4096. Shouldn't it be 4 KB?
Post by Andrei Borzenkov
Post by 4javier
You're right. My fault thinking that "chainloader" command would have ran
directly the chained bootloader with no need of "boot" command. Anyway, I
just tried, and shell just shows a blinking cursor on a new line, doing
nothing.
Well ... chainloader command loads single sector. El Torito boot image
can be of arbitrary (withing some limits) length. As soon as
isolinux.bin exceeds 512 bytes, it's going to fail.
Second problem is whether isolinux.bin was built for specific memory
address and for which one (this information is present in El Torito
boot catalog and is missing here of course).
Third consideration is, block size on CD is 2048 bytes which does not
match what you have on HDD (either 512 or 4096). It will likely make
it impossible for isolinux.bin to read anything.
Post by 4javier
Post by Andrei Borzenkov
Post by 4javier
chainloader /isolinux/isolinux.bin
I always get Error: Invalid Signature.
If I try to force chainloading, it just get back to the prompt.
Every loader command in grub just "get back to prompt". You need to
use "boot" command to actually jump to loaded code (but I doubt it
will work).
Jordan Uggla
2016-02-08 07:48:10 UTC
Permalink
Post by Andrei Borzenkov
Post by 4javier
Ok. Forget my last message. 2 KB was the actual dimension of the file, ls
shows that on my filesystem the file correctly takes 4 KB.
Back to topic, as far as I understand, there's no way to chainload isolinux
bootloader from grub. Some days ago I tried the procedure through loopback
device, with the same result. I think the created loop device is not exactly
an iso filesystem, right?
Created loop device is exactly what is in file it is created from. The
main problem is, once you leave GRUB this "device" is no more present.
You would need to implement something like syslinux memdisk to hook
into INT13 and emulate BIOS device. This is not impossible (GRUB
already has INT13 handler to implement partition remapping).
Secondary consideration remains - chanloader is not really suitable
for it. CD-ROM boot protocol is sufficiently different from standard
HDD handover. This again is not impossible, but someone will need to
implement it.
And on top of that, there is the tertiary consideration that almost
any operating system that you boot this way will fail to find its root
filesystem once the bootloader hands over control to the kernel and
its native hardware access.

http://www.supergrubdisk.org/wiki/Loopback.cfg is a standard that
tries to solve this type of problem in a different way, and even
worked with older versions of System Rescue CD. (They removed the
loopback.cfg from their images for reasons that no longer apply, so I
should ask them to add it back again).
--
Jordan Uggla (Jordan_U on irc.freenode.net)
4javier
2016-02-08 13:35:25 UTC
Permalink
Kali Linux ships the loopback.cfg, but sincerely, I don't see any advantage
in using it instead of creating a simple loopback menu entry in my own
grub.cfg. Loopback.cfg is minimal, doesn't provide all the entries of their
isolinux menu.
Post by 4javier
Post by Andrei Borzenkov
Post by 4javier
Ok. Forget my last message. 2 KB was the actual dimension of the file,
ls
Post by Andrei Borzenkov
Post by 4javier
shows that on my filesystem the file correctly takes 4 KB.
Back to topic, as far as I understand, there's no way to chainload
isolinux
Post by Andrei Borzenkov
Post by 4javier
bootloader from grub. Some days ago I tried the procedure through
loopback
Post by Andrei Borzenkov
Post by 4javier
device, with the same result. I think the created loop device is not
exactly
Post by Andrei Borzenkov
Post by 4javier
an iso filesystem, right?
Created loop device is exactly what is in file it is created from. The
main problem is, once you leave GRUB this "device" is no more present.
You would need to implement something like syslinux memdisk to hook
into INT13 and emulate BIOS device. This is not impossible (GRUB
already has INT13 handler to implement partition remapping).
Secondary consideration remains - chanloader is not really suitable
for it. CD-ROM boot protocol is sufficiently different from standard
HDD handover. This again is not impossible, but someone will need to
implement it.
And on top of that, there is the tertiary consideration that almost
any operating system that you boot this way will fail to find its root
filesystem once the bootloader hands over control to the kernel and
its native hardware access.
http://www.supergrubdisk.org/wiki/Loopback.cfg is a standard that
tries to solve this type of problem in a different way, and even
worked with older versions of System Rescue CD. (They removed the
loopback.cfg from their images for reasons that no longer apply, so I
should ask them to add it back again).
--
Jordan Uggla (Jordan_U on irc.freenode.net)
Loading...