0

I'm looking for a way to learn about and understand this technique. Here's what I'm talking about:

  • Slax boots, {does stuff, like copy itself to RAM}, then transitions control to the kernel/file system it just made
  • SYSLINUX boots off a FAT32/NTFS system, {does stuff}, then boots into a kernel
  • ISOLINUX boots off a CD/DVD, {does stuff} then boots into a kernel

Is there a name for this? Is it similar in GRUB when using chainloading?

  • GRUB boots, loads selection menu, does selection. If it's a chainloading selection, it passes control to something else.

I'm looking for how I can use one kernel to extract an .iso (from a FAT32/NTFS partition) into RAM, then boot off the RAM drive as if it had been there at startup. For more details as to why I want to do this, see this question.

Here, however, I'm just asking for details about how a kernel "transitions" to another. Is there a name for this? I've heard of INT13h which I believe is used in GRUB/chainloading. Is this a technique to 'reboot into a different kernel'? If not, how is this done?

  • "see this question" … it appears you've lost a link there. – derobert Feb 23 '13 at 22:34
  • Sorry about that - it's linked now. – Ehryk Feb 24 '13 at 0:49
  • 1
    int 13h is just the bios disk read service. – psusi Feb 24 '13 at 4:56
  • You are mixing here things up, the bootloader loads the kernel and the initrd at a specific location and just jumps to the location. The memory layout etc. has to be known by the kernel and the bootloader see kernel.org/doc/Documentation/x86/boot.txt for the x86 boot protocol. There is no kernel replacement or anything like that. – Ulrich Dangel Feb 24 '13 at 12:58
  • Indeed, I'm trying to understand this. Basically; it's say I <somehow> build a proper ext3 file system in RAM after booting into SYSLINUX, making a 1GB RAM partition, and copying a linux distro into the ext3 'disk'. How do I then 'boot to' the ext3 partition in memory as though it had been there from boot? – Ehryk Feb 24 '13 at 22:07
2

I'm guessing this is how: http://linux.die.net/man/8/kexec

kexec(8) - Linux man page

Name

kexec - directly boot into a new kernel

Synopsis

/sbin/kexec [-v (--version)] [-f (--force)] [-x (--no-ifdown)] [-l (--load)] [-p (--load-panic)] [-u (--unload)] [-e (--exec)] [-t (--type)] [--mem-min=addr] [--mem-max=addr]

Description

kexec is a system call that enables you to load and boot into another kernel from the currently running kernel. kexec performs the function of the boot loader from within the kernel. The primary difference between a standard system boot and a kexec boot is that the hardware initialization normally performed by the BIOS or firmware (depending on architecture) is not performed during a kexec boot. This has the effect of reducing the time required for a reboot. Make sure you have selected CONFIG_KEXEC=y when configuring the kernel. The CONFIG_KEXEC option enables the kexec system call.

1

Int 13 is an interrupt - '13' in particular is an entry point into the BIOS/Firmware disk services/API - so you can do disk IO (input/output) using this particular interrupt. There are other interrupts as well Int 9, etc. Interrupts are a way to switch execution context from your program into firmware/BIOS, OS drivers/OS, etc to get help from firmware. GRUB uses INT 13 during the initial stages of loading the bootloader from hard disk when the OS kernel is not in memory and it needs to load itself (stage1, stage 1.5, modules, etc) so Grub basically relies on the BIOS/Firmware to do the work of loading parts of GRUB.

The easiest way to load an ISO from file-system is to boot the ISO using GRUB loopback/loop module. GRUB has to be installed on hard disk on the MBR preferably and when you boot the machine, at the GRUB boot menu, you start typing GRUB commands to load the ISO from whatever file-system it resides on. You don't need a kernel to extract an ISO into ramdisk - GRUB can do all of that directly without relying on another kernel.

eg for Debian might look like this: insmod loopback linux (hd0,1)/deb.iso/install.amd/vmlinuz initrd (hd0,1)/deb.iso/install.amd/initrd.gz boot

(you need to check what modules are available to GRUB and if this is a EFI|BIOS boot)

Chainloading is using GRUB/Bootloader to load another OS, by booting another GRUB/Syslinux/Bootloader. Usually you do: GRUB-MBR--->vmlinuz Chianloading you do: GRUB-MBR--->CDROM-GRUB-MBR--->vmlinuz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.