Hot patching *nix

NogginBoink

Diamond Member
Feb 17, 2002
5,322
0
0
My roommate claims he can recompile his *NIX kernel and install the new one without rebooting.

How does *NIX do this? How can a process save context while swapping the binary out from under itself?

I'm skeptical.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Supposedly it can, if you don't value stability or data. You don't have to worry about the processes... so long as the entry points for system/kernel calls are still in the same place, the running processes won't know the difference. The question is... will the new kernel properly find all the open files, memory map, and so on. If anything is changed that ends up putting data in different places or stores something differently, I'd expect a hosed system.

Anyway, get him to demonstrate. In the mean time, enjoy your kernel that doesn't ever need to be recompiled to install new drivers or fix esoteric virtual memory issues, or blow up filesystems every few revisions ;).
 

dszd0g

Golden Member
Jun 14, 2000
1,226
0
0

Solaris is the only *nix I am aware of that actually update its running kernel without a reboot, but even Sun recommends applying those patches in single user mode with a reboot. There have been a few patches that have caused issues when applied without the safer procedure.

Most of the commercial Unices: AIX, HP-UX, Irix, SunOS (pre-Solaris), Tru64/Digital Unix/OSF/Ultrix (and conservative Solaris admins) apply kernel patches in single user mode (the fastest way to get into with out problems is to generally reboot) and then a second reboot after the patch(es) are applied. One can replace the Linux kernel while the system is running, but it doesn't take effect until a reboot.

Where *nix is much better is everything other than the kernel. One never (I should say almost there may be one or two evil programs out there) needs to reboot a *nix box when installing an application. Daemons (Services) can be upgraded and then restarted. If a daemon crashes, one just restarts it. In addition, programs run as normal users should not be able to take the system with it. If mozilla crashes on a Unix box it should never take the machine down with it (I have seen Web browsers crash Windows and pre X Macs).

Once you start running X-Windows though, all bets are off as X-Windows runs as root and especially with games I have seen it take the whole system down. Under the commercial Unices sometimes X-Windows locks up but not the whole machine. If one knows the hotkey one can restart X-Windows without rebooting, but one still generally loses everything one was working on.
 

dszd0g

Golden Member
Jun 14, 2000
1,226
0
0

Originally posted by: CTho9305

Anyway, get him to demonstrate. In the mean time, enjoy your kernel that doesn't ever need to be recompiled to install new drivers or fix esoteric virtual memory issues, or blow up filesystems every few revisions ;).

For commerical Unices hardware is rarely added that requires a change to the kernel. For Linux most distributions provide several standard kernels that they keep up to date. With Debian for example, one can just apt-get or dselect a new kernel. Redhat makes extensive use of modules and has scripts that run at startup that detect new hardware and configure it (I will admit this doesn't always work, kind of like plug & pray).

Even if one does enjoy configuring and compiling one's own kernel (I do) it is still often less trouble then getting some Windows drivers working properly. If one knows one is planning on purchasing a new piece of hardware, one can compile that into the kernel ahead of time so that when one does purchase it one just plugs it in. If one doesn't mind a large modular kernel one can compile modules for just about everything one could possible plan on purchasing (that is supported by Linux) and when one does purchase one of them, one just needs to load the module.

It's not quite as difficult as you make it sound.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
I know, I was just poking fun. The customizability is very useful, and it is pretty simple to do.