DEV Community

Abdenour ALIANE
Abdenour ALIANE

Posted on • Edited on

Install Linux 6.2 (and 6.3) on Google Cloud Compute Engine instance

Update : Use the same trick to install Version 6.3 !
6.2 is here, here is what's new, but we will not focus on that, but how to try it on Google Cloud !

Be careful, this is an unsigned kernel, The system will fail to boot in a secure boot environment !

Before we start, I need you to do two important steps, so in case something goes wrong, you can always go back :

1- You need ton install the Ops Agent so you can see what happens inside your instance,
2- Create a backup or make a snapshot and create a disk from this snapshot.

Create a snapshot,
snapshot

Covert it to disk to be attached to the instance
convert

Now that you took care of the backup plan, let's dive in !

Here is what we do have with a default Ubuntu 18.04 installation (there is also 20.04 and 22.04 as LTS, but here, we want just to make a small demo) :

kernel 0

We need to add mainline package to our repos list so we can install it using apt

sudo add-apt-repository ppa:cappelikan/ppa

Then update the new repos by

sudo apt update

then we just install it using

sudo apt install -y mainline

To get all available kernels, we just make

mainline --list

mainline list

Then, we choose what to install, by explicitly giving the version,

sudo mainline --install 6.2.0

or, if we want to get the latest stable kernel, we simply :

sudo mainline --install-latest

Restart, and voilà !

voila

...

But here is an issue, how do we go back to old kernel ?

The problem here, is we are accessing using SSH, and kernel selection is done from Grub Menu, and SSH is not available at this stage, which means we need another way, here is how !

Here is what we have now as installed kernels, we can use one of this commands :

dpkg --list | grep -i linux-image

apt list --installed | grep -i linux-image

installed kernels

Now, let's change something in default grub loading, here is the trick, but before, we need to understand how Grub works :

  1. Grub menu on a machine that we have physical access can be tuned to show a menu at restart, so we generally have two options (menu) : the default kernel, and advanced mode that have a submenu, and they are assigned by indexes starting with 0 :
    1- first menu entry = 0
    2- second menu entry = 1
    and so on ...
    and each menu has a submenu with index numbers, but to not complicate this, we will flatten this submenus to make it easier

  2. Grub saves its file to /boot/grub/grub.cfg , but this file should never be modified manually, as it's a result of some scripts (that we will know shortly), so eachtime for example we do a kernel update, it will be erased a new one will be generated, so we need to modify this script that generates the file, and not the file itself :

balak!

  1. The files that we need to modify for our case is /etc/default/grub

grub

And as you can see, the first option is 0 which means take the first entry in the menu and validate it, we will change that, but first we need to :

  • flatten the menu to avoid submenus
  • get the index of the kernel version we need

Here is how it was with default values (with submenus):

submenu

Let's first add this entry to disable submenus :

GRUB_DISABLE_SUBMENU=y

disable

Then let's validate the config by running the script to re-generate the /boot/grub/grub.cfg by running :

sudo update-grub

And it's flat now, no more submenus !

flat

Now we need to understand the origin of other variables from other files, so when we do update-grub there is also a bunch of scripts that runs from /etc/grub.d/

grub.d

On Google Cloud, there is another file, which is :

/etc/default/grub.d/50-cloudimg-settings.cfg

hidden

So let's change this value, it will override the global one ...

But to replace it with what ?

Well, let's enumerate the menus we got starting with zero
enum

So now that we know that we need entry 2 let's replace it :

bzzz

Restart, and voilà again !

voilo

Top comments (0)