Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to shutdown linux kernel and resume in Real Mode?

Let's say I'd like to start a small linux distro before my ordinary operating system start.

  1. BIOS load MBR and execute MBR.
  2. MBR locates the active partition which is my linux partition.
  3. Linux start and I perform what I need to do.
  4. Linux shut down and I switch to Real Mode again.
  5. The original partition boot sector is loaded and my ordinary OS start.

AFAIK, step 4 will be the difficult task, restore the state on all devices prior to linux, will INT13h be functional? Do I need to restore the Interrupt Vector Table? To mention a few.

Has this been done in any existing project perhaps?

like image 813
Jonas Engström Avatar asked Mar 01 '23 18:03

Jonas Engström


1 Answers

Linux does not normally support this, particularly since it reinitializes hardware in a way that the BIOS and DOS programs may not expect. However, there is some infrastructure to switch back to real mode in specific cases - particularly, for a reboot (see machine_real_restart in arch/x86/kernel/reboot.c) - and has code to reinitialize hardware for kexec or suspend. I suspect you might be able to do something with a combination of these - but I don't know if the result will truly match what DOS or Windows would expect to see on reboot.

A much easier plan would be to use a chainloading bootloader that can be set to boot in a particular configuration once, like GRUB. You could invoke grub-set-default, then reboot. When GRUB comes up, it would then pass control off to Windows. By then setting the fallback OS to the Linux partition, control would return to Linux on the next boot.

Yet another option may be to use Coreboot, but I'm not sure if this is production-ready for booting windows yet.

like image 195
bdonlan Avatar answered Apr 28 '23 20:04

bdonlan