I recently deleted my active Linux kernel and continued using the system as if nothing drastic happened. Are there any side-effects to deleting the Linux kernel that's currently in use? What about other non-Windows kernels?
2 Answers
The Linux kernel is completely loaded into RAM on boot. After the system is booted, it never goes back and tries to read anything from that file. The same goes for drivers, once loaded into the kernel.
If you deleted the only kernel image on disk, the only consequence is that the system cannot be successfully rebooted unless you install a replacement kernel image before reboot.
As for other OSes, I imagine it is the same, simply due to the nature of OS kernels. They're intentionally small bits of code that stay running all the time, so there is no incentive to keep going back to disk to "look" at the code again. It's always in memory. (RAM or VM.)

- 72,032
Well, if you have proper access and ironically, kernel support for /dev/kmem
you can overwrite the running kernel in RAM. Completely accomplishable with dd
or cat
. You'll likely either make the kernel panic or the machine lockup.
There's a kernel option that "netuers" /dev/kmem
where it only allows access to certain address ranges (PCI address space among others) that I would imagine is enabled in most distro stock kernels so you likely wouldn't get anywhere doing it on a real system unless you compiled the kernel youself. But... try this out on an instance of Linux running in your browser completely in Javascript: cat /dev/zero > /dev/ram
- something similar would happen on a real system.
However, Linux provides a feature (optional) called kexec
which will load in another kernel and then execute it, overwriting the currently executing kernel. To do this safely it must be done when no drivers/devices/files are active, i.e. the system must go through its shutdown procedures, unmounting all disks, etc. just as it were shutting down before the "handoff." Can be used to reboot a system without going through the BIOS. You can also totally ignore all these precautions and kexec
to a kernel or any code if you like in the middle of a running system - at the risk of corruption similar to powering off without a proper shutdown.

- 10,992
rmmod
. They can't beinsmod
ed back in if they are deleted from /lib/modules. – LawrenceC Dec 27 '11 at 01:39