0

I want to continue installing ubuntu without its kernel being upgrade. Any suggestions how can I do it?

Thanks, Zain

1 Answers1

2

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.

Building Your Own Kernel, Just the Basics

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)

Getting the Right Kernel Build Line from Ubuntu

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

Setup the git-repository For The Kernel of Interest

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

Building the Kernel

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

Let's do the update, per the Original Question

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
Fabby
  • 34,259
  • How about including debconf priority in preseed file. I just got this on google. I can have ubuntu OS start with ld kernel version and other package using my usb but when I am pxebooting it is going out to internet and getting the latest kernel. – zainsyed Nov 12 '18 at 19:39
  • Keitai Welcome to Ask Ubuntu! ;-) It's OK to point to another answer as you did here (if you need to add specifics to that answer). However, could you [edit] and expand with exact commands the second part as you're talking to a rep 1 user and most of the time, they need a bit of hand-holding. Then leave a comment @Fabby and I'll come back and upvote. – Fabby Nov 12 '18 at 22:29
  • @Fabby Please let me know if that's what you meant. I tested this out as I was writing it, but the build is ongoing. I'll come back and edit if there are problems with the last bit. – Keitai Otaku Nov 12 '18 at 23:45
  • Don't do the 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