I want to switch between different version of kernel installed on my system without reboot.
That is to say if i have '3.0.0-16-generic
kernel currently running and i have older kernel 3.0.0-14-generic
also there, then I maybe be able to switch to 3.0.0-14-generic
(the other kernel) without rebooting .
(I need to do live kernel debugging and making changes so in order to do so i can't reboot)
There is no way to swap out two complete Kernels. I'm sure you can understand the significance of a monolithic kernel like Linux and why that makes it impossible to simply replace.
The closest you can get is a live-patching process using Ksplice. It converts Kernel updates into magical shims that can plug holes in a running Kernel, allowing you to keep the computer on indefinitely without needing a reboot. For your purposes, it also lets you roll back changes.
It is free for Ubuntu Desktop editions so you can play around with it but you have to pay a subscription for servers (where this sort of thing is most needed).
Just seen your edit. Ksplice probably isn't going to help if you're manually hacking and building your own Kernels for debugging as "the service" is that they provide the special updates and they're not something you can generate on your own.
If you're just building things against an official kernel, it might still work.
One more idea: Virtualisation. You could build your new kernel and swap things around in your VM and reboot. It's still going to take the time it needs to reboot but you could make the VM much more light than your development machine (base it on Ubuntu Server, drop the X server if you don't need it, etc).
As Oli mentioned, your best shot is probably virtualisation.
That said, if you're tinkering with hardware, virtualisation might not cut it for you, in which case, you could use
kexec
to swap the running kernel without a full reboot.Taken from the ArchWiki
kexec
page:Note that the above will still restart all services, including your init system, the display server, networking, etc. However, if you use a fast enough init system, like
systemd
, your can boot into your new kernel in 2-3 seconds, since you're bypassing the BIOS/UEFI and the bootloader.A similar description can be found on the RapidReboot Ubuntu Wiki page.
I think these answers need to be updated.
There is kpatch now, which is more native than ksplice et al.
It can’t change in-kernel data structures though, for obvious reasons, so it’s mostly useful for security hotpatches.
The general problem always is: Running processes still keep kernel data structures around, expecting kernel functions to expect them and give them back. And without those processes being made for it, it is not really possible to know, if that is the case. So you can’t change those, until all processes that use them, are restarted. It would require live-patching all those programs too.
And I didn’t even mention driver changes, when the hardware is in a special state. (Same problem as with kexec.)