I want to continue installing ubuntu without its kernel being upgrade. Any suggestions how can I do it?
Thanks, Zain
This is an interesting problem. I don't think you can do an automatic upgrade while preserving the kernel, as the upgrade process will update grub to point to the new kernel. It should preserve your previous kernel.
The easiest way to deal with this then, is to do the full update, but before allowing the machine to reboot, go back into grub and have it point to your old kernel. That process is discussed here:
Set "older" kernel as default grub entry
You can also download the kernel source, git-checkout the precise version of the kernel you wish to build, rebuild the source, then do the update (without rebooting), and then install the kernel and modules from your build directory (which writes grub automatically, overwriting whatever happened in the update).
This second path has the added benefit of allowing you to pick and choose precisely which version of the kernel you get. Building the Ubuntu Kernel is described here:
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
I would use the git-clone option, instead of apt-get, it seems a little more straight-forward to me.
Just to give you a few specifics of how you would do this, and how you would install the kernel, assuming git is installed, and sufficient disk space (say about 25GB free). All of this is documented above in the normal Ubuntu wiki space, but that might be difficult to digest.
There's a couple of packages you'll need, so
sudo apt-get build-dep linux-image-$(uname -r)
You'll need to know what Ubuntu release-line you are on.
lsb_release --short --code
bionic
And then you can clone the specific Ubuntu kernel line for your current Ubuntu revision, which for me is bionic.
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git
cd ubuntu-bionic
Now, at this point you need to select the commit id associated with the kernel version of interest.
To find the kernel version you are using
uname --kernel-release
For me this returns 4.15.0-38-generic. The Ubuntu release process tags different commits, in this case, they use "Ubuntu-.". Since we may not know the extra, to find the tag for your particular release
git tag | grep 4.15.0.38
Which returns Ubuntu-4.15.0-38.41, so let's check this out so we can build it; we're just checking out in headless mode, because at this point we're not trying to modify any code, just rebuild existing code.
git checkout Ubuntu-4.15.0-38.41
Let's get the config file for the machine, for this particular Ubuntu kernel revision. This is critical to ensure you are actually building the kernel of interest.
cp /boot/config-4.15.0.38-generic .config
And Let's verify that the .config file is ok.
make oldconfig
if the above option prompts you for any questions, your .config
file doesn't match the commit-id you've checked out for the kernel. Please try again.
If you are actually TRYING to upgrade the kernel version to a newer one, you'll probably get prompted for new options. To just accept the defaults you can use:
yes '' | make oldconfig
Now, let's build the kernel and the kernel modules. Use -jX where X is the number of threads your build machine supports. If you don't know get it from /proc/cpuinfo, for example:
calc $(cat /proc/cpuinfo | grep processor | tail -1 | sed -e 's/.* //') + 1
This returns 8 for my build server, so -j8:
make -j8 vmlinux bzImage modules
sudo apt-get update; sudo apt-get upgrade
That will upgrade the machine, potentially overwriting the kernel version your machine boots with. To install the new kernel and make it the default:
sudo make modules_install; sudo make install
UbuntuPrompt>
thingy, because no one else on the site is doing that here and you risk that a less than stellar OP, will actually copy-paste that into their terminal too... ;-) >:-) You had a +1 already and now another one! :-) Please review my edits and also review the editing help to improve the readability of your answers in the future... ;-) – Fabby Nov 14 '18 at 00:45