Page MenuHomeDevCentral

Determine how to boot a custom kernel image on a Scaleway server
Open, HighPublic

Description

We'd like to be able to set a specific kernel version to be able tu update kernel as we want on Scaleway infrastructure.

That would benefit to Eglide.

Related Objects

StatusSubtypeAssignedTask
OpenNone

Event Timeline

dereckson triaged this task as High priority.Mar 11 2022, 23:43
dereckson created this task.
dereckson added a parent task: Unknown Object (Maniphest Task).

I spawned a DEV1-S machine with ubuntu 22.04 in order to make the tests:

Let's check the content of the boot partition and the kernel in use:

root@scw-zen-villani:~ # ll /boot/
total 171065
drwxr-xr-x  4 root root      4096 Sep 22 21:22 ./
drwxr-xr-x 20 root root      4096 Sep 22 21:20 ../
-rw-------  1 root root   6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-r--r--  1 root root    261649 Jun 22 12:42 config-5.15.0-41-generic
drwx------  3 root root       512 Jan  1  1970 efi/
drwxr-xr-x  6 root root      4096 Aug  2 12:44 grub/
lrwxrwxrwx  1 root root        28 Jul 18 02:10 initrd.img -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root  31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
lrwxrwxrwx  1 root root        28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 126457768 Sep 20 10:48 linux-5.15.69.tar.xz
lrwxrwxrwx  1 root root        25 Jul 18 02:10 vmlinuz -> vmlinuz-5.15.0-41-generic
-rw-------  1 root root  11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
lrwxrwxrwx  1 root root        25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic
root@scw-zen-villani:/boot# uname -r
5.15.0-41-generic

Let’s download and install a latest version of the kernel

root@scw-zen-villani:~# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.19/amd64/linux-headers-5.19.0-051900_5.19.0-
root@scw-zen-villani:~# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.19/amd64/linux-headers-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb
root@scw-zen-villani:~# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.19/amd64/linux-image-unsigned-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb
root@scw-zen-villani:~# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.19/amd64/linux-modules-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb

root@scw-zen-villani:~# dpkg -i *deb
Selecting previously unselected package linux-headers-5.19.0-051900-generic.
(Reading database ... 71272 files and directories currently installed.)
Preparing to unpack linux-headers-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-headers-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-headers-5.19.0-051900.
Preparing to unpack linux-headers-5.19.0-051900_5.19.0-051900.202207312230_all.deb ...
Unpacking linux-headers-5.19.0-051900 (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-image-unsigned-5.19.0-051900-generic.
Preparing to unpack linux-image-unsigned-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-modules-5.19.0-051900-generic.
Preparing to unpack linux-modules-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-modules-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Setting up linux-headers-5.19.0-051900 (5.19.0-051900.202207312230) ...
Setting up linux-headers-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Setting up linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
I: /boot/vmlinuz is now a symlink to vmlinuz-5.19.0-051900-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.19.0-051900-generic
Setting up linux-modules-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Processing triggers for linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.19.0-051900-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.19.0-051900-generic
Found initrd image: /boot/initrd.img-5.19.0-051900-generic
Found linux image: /boot/vmlinuz-5.15.0-41-generic
Found initrd image: /boot/initrd.img-5.15.0-41-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

We can notice that it changed the symlinks in boot, as well as the grub configuration:

root@scw-zen-villani:/boot# ll
total 257161
drwxr-xr-x  4 root root      4096 Sep 22 21:27 ./
drwxr-xr-x 20 root root      4096 Sep 22 21:20 ../
-rw-------  1 root root   6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-------  1 root root   6391505 Jul 31 22:30 System.map-5.19.0-051900-generic
-rw-r--r--  1 root root    261649 Jun 22 12:42 config-5.15.0-41-generic
-rw-r--r--  1 root root    269041 Jul 31 22:30 config-5.19.0-051900-generic
drwx------  3 root root       512 Jan  1  1970 efi/
drwxr-xr-x  6 root root      4096 Sep 22 21:27 grub/
lrwxrwxrwx  1 root root        32 Sep 22 21:26 initrd.img -> initrd.img-5.19.0-051900-generic
-rw-r--r--  1 root root  31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root  69646254 Sep 22 21:27 initrd.img-5.19.0-051900-generic
lrwxrwxrwx  1 root root        28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 126457768 Sep 20 10:48 linux-5.15.69.tar.xz
lrwxrwxrwx  1 root root        29 Sep 22 21:26 vmlinuz -> vmlinuz-5.19.0-051900-generic
-rw-------  1 root root  11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
-rw-------  1 root root  11848864 Jul 31 22:30 vmlinuz-5.19.0-051900-generic
lrwxrwxrwx  1 root root        25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic

Let’s reboot and check if it worked

root@scw-zen-villani:~# reboot
root@scw-zen-villani:~# Connection to 212.47.244.42 closed by remote host.
Connection to 212.47.244.42 closed.

root@scw-zen-villani:~# uname -r
5.19.0-051900-generic

Now, let’s try to rollback to 5.15.0-14-generic. Let’s update the symlinks first.

root@scw-zen-villani:~# linux-update-symlinks upgrade 5.15.0-41-generic /boot/vmlinuz-5.15.0-41-generic

root@scw-zen-villani:~# ll /boot
total 257161
drwxr-xr-x  4 root root      4096 Sep 22 21:35 ./
drwxr-xr-x 20 root root      4096 Sep 22 21:35 ../
-rw-------  1 root root   6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-------  1 root root   6391505 Jul 31 22:30 System.map-5.19.0-051900-generic
-rw-r--r--  1 root root    261649 Jun 22 12:42 config-5.15.0-41-generic
-rw-r--r--  1 root root    269041 Jul 31 22:30 config-5.19.0-051900-generic
drwx------  3 root root       512 Jan  1  1970 efi/
drwxr-xr-x  6 root root      4096 Sep 22 21:27 grub/
lrwxrwxrwx  1 root root        28 Sep 22 21:35 initrd.img -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root  31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root  69646254 Sep 22 21:27 initrd.img-5.19.0-051900-generic
lrwxrwxrwx  1 root root        28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 126457768 Sep 20 10:48 linux-5.15.69.tar.xz
lrwxrwxrwx  1 root root        25 Sep 22 21:35 vmlinuz -> vmlinuz-5.15.0-41-generic
-rw-------  1 root root  11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
-rw-------  1 root root  11848864 Jul 31 22:30 vmlinuz-5.19.0-051900-generic
lrwxrwxrwx  1 root root        25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic

By default, grub set latest kernel as the bootable one.
Let’s change it back to 5.15.0-41-generic

root@scw-zen-villani:/boot# vim /boot/grub/grub.cfg

We change this entry

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-136735fa-5cc1-470f-9359-ee736e42f844' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        search --no-floppy --fs-uuid --set=root 136735fa-5cc1-470f-9359-ee736e42f844
        linux   /boot/vmlinuz-5.19.0-051900-generic root=UUID=136735fa-5cc1-470f-9359-ee736e42f844 ro  swiotlb=262144 console=tty1 console=ttyS0
        initrd  /boot/initrd.img-5.19.0-051900-generic
}

To

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-136735fa-5cc1-470f-9359-ee736e42f844' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        search --no-floppy --fs-uuid --set=root 136735fa-5cc1-470f-9359-ee736e42f844
        linux   /boot/vmlinuz-5.15.0-41-generic root=UUID=136735fa-5cc1-470f-9359-ee736e42f844 ro  swiotlb=262144 console=tty1 console=ttyS0
        initrd  /boot/initrd.img-5.15.0-41-generic
}
root@scw-zen-villani:/boot# reboot
Connection to 212.47.244.42 closed by remote host.
Connection to 212.47.244.42 closed.

 root@scw-zen-villani:~# uname -r
5.15.0-41-generic

Let’s reupdate grub and reboot

root@scw-zen-villani:~# /etc/kernel/postinst.d/zz-update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.19.0-051900-generic
Found initrd image: /boot/initrd.img-5.19.0-051900-generic
Found linux image: /boot/vmlinuz-5.15.0-41-generic
Found initrd image: /boot/initrd.img-5.15.0-41-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
root@scw-zen-villani:~# reboot

root@scw-zen-villani:~# uname -r
5.19.0-051900-generic

And in case of hard reboot

root@scw-zen-villani:~# uname -r
5.19.0-051900-generic

What if we stop and run again the instance, it keeps symlinks as is?

It seems to, on a brand new DEV1-S machine:

root@scw-awesome-hawking:~# uname -r
5.15.0-41-generic
root@scw-awesome-hawking:~# ll /boot
total 47569
drwxr-xr-x  4 root root     4096 Jul 18 02:11 ./
drwxr-xr-x 20 root root     4096 Sep 23 18:36 ../
-rw-------  1 root root  6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-r--r--  1 root root   261649 Jun 22 12:42 config-5.15.0-41-generic
drwx------  3 root root      512 Jan  1  1970 efi/
drwxr-xr-x  6 root root     4096 Aug  2 12:44 grub/
lrwxrwxrwx  1 root root       28 Jul 18 02:10 initrd.img -> initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
lrwxrwxrwx  1 root root       28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
lrwxrwxrwx  1 root root       25 Jul 18 02:10 vmlinuz -> vmlinuz-5.15.0-41-generic
-rw-------  1 root root 11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
lrwxrwxrwx  1 root root       25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic

root@scw-awesome-hawking:~# dpkg -i *deb
Selecting previously unselected package linux-headers-5.19.0-051900-generic.
(Reading database ... 71272 files and directories currently installed.)
Preparing to unpack linux-headers-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-headers-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-headers-5.19.0-051900.
Preparing to unpack linux-headers-5.19.0-051900_5.19.0-051900.202207312230_all.deb ...
Unpacking linux-headers-5.19.0-051900 (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-image-unsigned-5.19.0-051900-generic.
Preparing to unpack linux-image-unsigned-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Selecting previously unselected package linux-modules-5.19.0-051900-generic.
Preparing to unpack linux-modules-5.19.0-051900-generic_5.19.0-051900.202207312230_amd64.deb ...
Unpacking linux-modules-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Setting up linux-headers-5.19.0-051900 (5.19.0-051900.202207312230) ...
Setting up linux-headers-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Setting up linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
I: /boot/vmlinuz is now a symlink to vmlinuz-5.19.0-051900-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.19.0-051900-generic
Setting up linux-modules-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
Processing triggers for linux-image-unsigned-5.19.0-051900-generic (5.19.0-051900.202207312230) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.19.0-051900-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.19.0-051900-generic
Found initrd image: /boot/initrd.img-5.19.0-051900-generic
Found linux image: /boot/vmlinuz-5.15.0-41-generic
Found initrd image: /boot/initrd.img-5.15.0-41-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
root@scw-awesome-hawking:~# ll /boot
total 133665
drwxr-xr-x  4 root root     4096 Sep 23 18:45 ./
drwxr-xr-x 20 root root     4096 Sep 23 18:36 ../
-rw-------  1 root root  6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-------  1 root root  6391505 Jul 31 22:30 System.map-5.19.0-051900-generic
-rw-r--r--  1 root root   261649 Jun 22 12:42 config-5.15.0-41-generic
-rw-r--r--  1 root root   269041 Jul 31 22:30 config-5.19.0-051900-generic
drwx------  3 root root      512 Jan  1  1970 efi/
drwxr-xr-x  6 root root     4096 Sep 23 18:45 grub/
lrwxrwxrwx  1 root root       32 Sep 23 18:44 initrd.img -> initrd.img-5.19.0-051900-generic
-rw-r--r--  1 root root 31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 69646261 Sep 23 18:45 initrd.img-5.19.0-051900-generic
lrwxrwxrwx  1 root root       28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
lrwxrwxrwx  1 root root       29 Sep 23 18:44 vmlinuz -> vmlinuz-5.19.0-051900-generic
-rw-------  1 root root 11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
-rw-------  1 root root 11848864 Jul 31 22:30 vmlinuz-5.19.0-051900-generic
lrwxrwxrwx  1 root root       25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic

Now, halting then rebooting from the scaleway interface (instead of pressing the reboot button like tried before):

root@scw-awesome-hawking:~# uname -r
5.19.0-051900-generic
root@scw-awesome-hawking:~# ll /boot
total 133665
drwxr-xr-x  4 root root     4096 Sep 23 18:45 ./
drwxr-xr-x 20 root root     4096 Sep 23 18:48 ../
-rw-------  1 root root  6249967 Jun 22 12:42 System.map-5.15.0-41-generic
-rw-------  1 root root  6391505 Jul 31 22:30 System.map-5.19.0-051900-generic
-rw-r--r--  1 root root   261649 Jun 22 12:42 config-5.15.0-41-generic
-rw-r--r--  1 root root   269041 Jul 31 22:30 config-5.19.0-051900-generic
drwx------  3 root root      512 Jan  1  1970 efi/
drwxr-xr-x  6 root root     4096 Sep 23 18:45 grub/
lrwxrwxrwx  1 root root       32 Sep 23 18:44 initrd.img -> initrd.img-5.19.0-051900-generic
-rw-r--r--  1 root root 31096565 Jul 18 02:11 initrd.img-5.15.0-41-generic
-rw-r--r--  1 root root 69646261 Sep 23 18:45 initrd.img-5.19.0-051900-generic
lrwxrwxrwx  1 root root       28 Jul 18 02:10 initrd.img.old -> initrd.img-5.15.0-41-generic
lrwxrwxrwx  1 root root       29 Sep 23 18:44 vmlinuz -> vmlinuz-5.19.0-051900-generic
-rw-------  1 root root 11086240 Jun 22 13:24 vmlinuz-5.15.0-41-generic
-rw-------  1 root root 11848864 Jul 31 22:30 vmlinuz-5.19.0-051900-generic
lrwxrwxrwx  1 root root       25 Jul 18 02:10 vmlinuz.old -> vmlinuz-5.15.0-41-generic