reboot a running linux in pxe with kexec
I want to reboot a running linux in pxe mode, to connect to a fog server.
For this task, my current track is to use kexec.
I retreive the kernel image and the init from the tftp server (the fog server in our installation) from the directory …/fog/service/ipxe
kexec -l bzImage --init=init.xz # load the new kernel
kexec -e # replace current kernel with the loaded one
And it does not work (nothing is displayed).
Has anyone tried and succeed such a reboot from linux ?
Thanks in advance for any clue
Ok, it is quite simple with grub.
For instance, with a debian jessie:
- install ipxe with grub
apt-get install ipxe
- Set the next grub boot to use the ipxe menu
- Reboot !
The number to use is the number of the grub entry (counting the submenu) of the pxe entry, starting from 0.
Thank you for your help, I hope the result could help someone in the future.
@pga i do, but it would be more efficient to use grub to boot directly to the ipxe network boot file you want to use ;)
@Junkhacker that is equivalent to the grub + ipxe solution I think, and I don’t have to insert a CD in all my machines at least :-)
My absolute restriction is that I don’t have a physical access to each machine, only a root ssh access.
Or maybe you know a way to directly reboot to an iso located on a hard drive ?
you can also use the ipxe boot cd iso (downloadable from the ipxe website) to boot to pxe from a cd
@Junkhacker not every bios supports pxe unfortunately.
I am currently trying with grub and booting to ipxe, I’ll see what result it gives me.
can you not set these machines to boot to the network by default?
@Wayne-Workman I can go to a single machine, but not 200 of them in a reasonable time :-)
You have to remember, when linux loads it boots to an OS layer through a portion, essentially, that tells it how to use the root filesystem, or the initrd=init.xz argument as you described.
The problem is, you’re not loading the system when you’re using kexec. All you’re loading is a new kernel, not a new OS layer. I’m pretty sure you would not be able to do this as you’re thinking.
Wayne Workman last edited by
@pga I don’t think you could reinstall from scratch using an ISO… if you SSH’d into a fog host that has network booted, you’d simply get a bash prompt, and not the advanced iPXE menus that you want.
If possible, you’d need to just build an image for the box before hand and then image it with that.
To get it to network boot, you’d have to set up chain loading to the network on the HDD… and that’s going to be interesting to see… and I have no idea how to do it.
Why can’t you go to the machine?
@Wayne-Workman yes I have root ssh access. And you have expressed my request much better than me, thanks a lot.
Wayne Workman last edited by Wayne Workman
@Tom-Elliott Basically, I think he wants to configure/change a running machine so that next time it boots, it boots to the network (I assume to access a Linux install ISO)… because he can’t get to it to press the F-whatever key to make it boot from network.
@pga I am assuming you have SSH access?
The kernel that’s loaded to with the client is from the FOG Server, is there another kernel you’re referring to?
Can you show a layout and possible flow chart depicting what you’re describing?
No, I am not rebooting the client if using kexec, just replacing the current kernel with the kernel from the fog server.
It looks like a reboot, but it is not a reboot :-)
Let’s try to explain a little better:
I want to launch a reinstallation of a running linux computer. But I can’t access the machine to press the adequate key to select pxe boot at the reboot.
So I need a way to use the current linux kernel to do a kind of reboot, using the kernel and initrd from the fog server.
I hope my explanation is a little more clear.
I guess I don’t understand what you mean?
kexec would be used to switch the current running kernel, but if you are rebooting the client, it’s no longer using what you setup kexec for.
Maybe I’m mis-understanding?