Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
    
Actually you can tell kexec to load another kernel on panic. –  ultrasawblade Mar 23 '11 at 3:06
    
Not sure if it is still supported, but kexec is exactly what I was looking for. As for load times, on servers a lot of the kernel boot time is spent on in BIOS initializing memory and drive arrays. Briefly booting another Linux to run some scripts wouldn't greatly affect things. –  mfarver Mar 23 '11 at 14:23

Using GRUB, you could do something like this:

[root@localhost ~]# echo "savedefault --default=2 --once" | grub --batch
[root@localhost ~]# reboot

That instructs GRUB to bypass the timeout and default settings from /boot/grub.conf and boot entry 2 one time only. Using the --once flag ensures that on subsequent boots, the defaults in boot/grub.conf are followed.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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