Is it possible to shut down the Linux kernel and resume it in real time?

Let's say I would like to start a small Linux distribution before starting my regular operating system.

  • Booting the MBR BIOS and executing the MBR.
  • MBR finds the active partition, which is my Linux partition.
  • Linux starts up and I do what I need.
  • Linux shuts down and I switch back to Real mode again.
  • The initial boot sector of the partition boots and my normal OS starts.

AFAIK, step 4 will be a difficult task, to restore the state on all devices before Linux, will INT13h function? Do I need to restore the interrupt vector table? To mention a few.

Perhaps this was done in any existing project?

+4
source share
3 answers

Linux usually does not support this, especially because it reinitializes hardware so that BIOS and DOS programs may not be expected. However, there is a certain infrastructure for switching in real mode in specific cases - in particular, for rebooting (see Machine_real_restart in arch / x86 / kernel / reboot.c) - and has code for reinitializing equipment for kexec or pausing. I suspect you can do something with a combination of them, but I don’t know if the result will really match what DOS or Windows expected to see on reboot.

It is much simpler to plan to use a boot loader with a chain that can be configured to boot in a specific configuration once, for example GRUB , you can call grub-set-default, and then reboot. When GRUB comes up, it will take control of Windows. Then, by installing the backup OS on the Linux partition, control will return to Linux at the next boot.

Another option might be to use Coreboot , but I'm not sure if it is ready for release to load windows.

+4
source

I have not tried this, so I do not know if this will work, but here goes:

There is an option in the header of the bzImage kernel file that indicates the address of the real mode code that must be executed before the protected mode code is run. You can create a minimal bzImage compatible file that does not have a real kernel, but that has real mode code to load your MBR using INT 0x13 to 0x7c00 and jmp into it, as the BIOS does.

If you use kexec to load bzImage using the options β€œ-t bzImage-x86 - real-mode”, it should reset the PE bit in CR0 to move to realmode (as bdonlan above) and execute the code pointed to by the bzImage header option.

The bzImage header parameter is called realmode_swtch and is documented in / usr / src / linux / Documentation / x 86 / boot.txt, the header format code is in the directory / usr / src / linux / arch / x 86 / boot /. S

+3
source

Have you viewed kexec ?

+1
source

All Articles