Anyone know of a way to "boot" another Linux kernel from within Linux, discarding the original kernel/initrd? The idea is that I can boot my server from a small read only copy of Linux that does some housekeeping/data gathering tasks and then checks in with a management server to figure out what to do with the server. Most of the time that will be to just boot Linux/Windows off the local harddrives or image the box.
Basically, I want a tiny copy of Linux to be the bootloader, instead of a specialized (and less flexible) bootloader package. The tiny copy of Linux could be on a USB key, or delivered by PXE.
Loadlin used to do this for Windows, so I could create this environment in DOS... but networking can be tricky and I lose a lot of tools.
Other options are virtualization. All the automation above is part of the host OS, and it checks in with the management server to figure out guests to launch and the like. How the cloud servers do it. Or I could do some magic on the PXE side: PXE boot the data gathering copy of Linux first, make a change to the PXE server and reboot it with the second time it PXE booting a remote kernel but a local OS drive.
Well in a pure-linux setup, you have kexec which can be used to "reboot" the kernel/OS without having to reset the hardware / go through BIOS load again. Which works well for everything short of a kernel panic.
But in a mixed environment, I think Eater my have a the solution. Essentially you'd boot into your linux, run whatever scripts you need / do whatever housekeeping is required and then reboot into your OS of choice.
Mind you, however, that this leeds loads to freakishly slow load times. Granted you can optimize the linux boot times to a point where it may take a few of seconds, you still have to deal with loading the BIOS twice. All of which is visible to the user whom may then decide to freak out.
Using GRUB, you could do something like this:
That instructs GRUB to bypass the
timeout
anddefault
settings from/boot/grub.conf
and boot entry 2 one time only. Using the--once
flag ensures that on subsequent boots, the defaults inboot/grub.conf
are followed.To the best of my knowledge you can not boot a second kernel from inside of a currently running kernel.
You would be best to install a VM through Xen and have it perform the tasks through a virtual network interface. If you configure a new VM you will be able to use SSH to connect back to the host and run scripts and tools as you wish.
For what you are doing, this would be my choice.