1

Ubuntu 21.10.

I am building kernels as documented at https://help.ubuntu.com/community/Kernel/Compile and https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel.

DEB_BUILD_OPTIONS=parallel=$(getconf _NPROCESSORS_ONLN) AUTOBUILD=1 NOEXTRAS=1 \
    fakeroot debian/rules binary-arch

This compilation command has the same result:

make --jobs=$(getconf _NPROCESSORS_ONLN) bindeb-pkg \
    LOCALVERSION=-custom-$(git describe | tr '[:upper:]' '[:lower:]')

This creates some .deb packages:

$ ls -hal ../*.deb
-rw-r--r-- 1 amedee amedee 8,2M feb 26 02:17 ../linux-headers-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb
-rw-r--r-- 1 amedee amedee  70M feb 26 02:18 ../linux-image-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb
-rw-r--r-- 1 amedee amedee 1,2M feb 26 02:17 ../linux-libc-dev_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb

I install them like this:

sudo dpkg --install \
    ../linux-headers-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb \
    ../linux-image-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb

This is then the content of /boot:

$ ls -hal /boot/*5.13*
-rw-r--r-- 1 root root 252K nov  5 10:21 /boot/config-5.13.0-22-generic
-rw-r--r-- 1 root root 251K feb 26 02:15 /boot/config-5.13.19-ubuntu-5.13.0-22.22
-rw-r--r-- 1 root root  40M feb 22 16:21 /boot/initrd.img-5.13.0-22-generic
-rw-r--r-- 1 root root  37M feb 26 02:20 /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22
-rw------- 1 root root 5,7M nov  5 10:21 /boot/System.map-5.13.0-22-generic
-rw-r--r-- 1 root root 5,6M feb 26 02:15 /boot/System.map-5.13.19-ubuntu-5.13.0-22.22
-rw------- 1 root root 9,8M nov  5 13:51 /boot/vmlinuz-5.13.0-22-generic
-rw-r--r-- 1 root root 8,5M feb 26 02:15 /boot/vmlinuz-5.13.19-ubuntu-5.13.0-22.22

Update initramfs (which strictly speaking isn't necessary because that has already been done, but for good measure):

$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22
update-initramfs: Generating /boot/initrd.img-5.13.0-22-generic

Then I run update-grub:

amedee@kerbol:~/repos/ubuntu-impish$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.13.0-22-generic
Found initrd image: /boot/initrd.img-5.13.0-22-generic
Found linux image: /boot/vmlinuz-5.13.0-22-generic
Found initrd image: /boot/initrd.img-5.13.0-22-generic
Adding boot menu entry for UEFI Firmware Settings
done

My compiled kernel 5.13.19-ubuntu-5.13.0-22.22 is not added to the Grub menu by update-grub. I know I can add it manually, but that has a risk of typos. I also need to compile a lot of kernels because I'm trying to locate a possible bug using git bisect. The kernel issue that I'm troubleshooting does not occur in more recent mainline kernels, only in (some, but not all) Ubuntu 21.10 kernels, so I only do this to learn something and to satisfy my curiosity.

What do I need to do so that update-grub adds my compiled kernel from the /boot directory to the Grub menu?

  • The correct syntax is update-initramfs -u -k all and no that doesn't help, I'll add it to the question. – Amedee Van Gasse Feb 26 '22 at 12:56
  • Consider switching to the mainline kernel for kernel bisection. I have bisected the kernel many many times. I have never had any success attempting to compile the kernel using the Ubuntu methods. With mainline you can check the latest RC candidate to determine if your issue has already been fixed. You will have to re-establish your git bisect good and git bisect bad start points however. Using mainline also is better for upstream escalation. See my mainline kernel compile method here. – Doug Smythies Feb 26 '22 at 15:47
  • I never had an issue with update-grub with my custom compiles and do not know what is wrong there. – Doug Smythies Feb 26 '22 at 15:51
  • Hi @DougSmythies, I already know that the specific issue does not occur in the most recent mainline kernel, or any other mainline kernel that I have tested so far. I have already tried that. It only occurs with kernels from the Ubuntu repositories. My main motivation is to learn. If I would just switch to the most recent kernel, then it would be like giving up and I would not learn anything. – Amedee Van Gasse Feb 26 '22 at 17:32
  • @DougSmythies I have read your compilation method and I see that you use bindeb-pkg. In the end it doesn't matter - both methods create .deb packages, and with both methods, kernel files are copied to /boot. We both arrive at the same point via different methods. I will absolutely try with the mainline kernel repo, just to humor you, and I expect to get the same result. I don't think it's something with the kernels, but with the way how update-grub detects files in /boot. – Amedee Van Gasse Feb 26 '22 at 17:40
  • Before I used the Ubuntu way of compiling the kernel, I used this command: time make --jobs=$(getconf _NPROCESSORS_ONLN) bindeb-pkg LOCALVERSION=-$(git describe | tr '[:upper:]' '[:lower:]'). The result is the same. – Amedee Van Gasse Feb 26 '22 at 17:42
  • O.K. fair enough on the wanting to learn part. I agree grub-update should work. I am using 20.04, you are using 21.10 (I think). – Doug Smythies Feb 26 '22 at 18:47
  • That is correct, I will add that to the question. – Amedee Van Gasse Feb 27 '22 at 01:46
  • I do not know what this is: Found GRUB Invaders image: /boot/invaders.exec. Try shorter kernel names, just as a test. – Doug Smythies Feb 27 '22 at 16:55
  • That is just the very famous and legendary game Space Invaders, made to run inside GRUB, so without an operating system. See https://github.com/stokito/grub-invaders and a video of the gameplay https://www.youtube.com/watch?v=ZfddXQlF1vA – Amedee Van Gasse Feb 28 '22 at 03:19
  • I have uninstalled grub-invaders so you no longer have to worry about that. I will update the question accordingly. – Amedee Van Gasse Feb 28 '22 at 03:21
  • @karel I found that answer 23 hours before you posted your comment, see answer below. – Amedee Van Gasse Mar 01 '22 at 10:31
  • Heh heh, that's where I got it from. – karel Mar 01 '22 at 12:01

1 Answers1

0

The following three commands solve this problem, by turning off the executable bit on 09_lowlatency and turning on the bit for 10_linux, in accordance with the text in /etc/grub.d/README.lowlatency.

# chmod -x /etc/grub.d/09_lowlatency
# chmod +x /etc/grub.d/10_linux
# update-grub

Solution found at https://askubuntu.com/a/1228269/149519.

To confirm that it now works as expected:

$ ls -hal /boot ; echo ; sudo update-grub
total 107M
drwxr-xr-x  4 root root 4,0K feb 28 04:42 .
drwxr-xr-x 20 root root 4,0K feb 26 01:13 ..
-rw-r--r--  1 root root 252K nov  5 10:21 config-5.13.0-22-generic
-rw-r--r--  1 root root 251K feb 26 02:15 config-5.13.19-ubuntu-5.13.0-22.22
drwx------  4 root root 4,0K jan  1  1970 efi
drwxr-xr-x  5 root root 4,0K feb 28 04:42 grub
lrwxrwxrwx  1 root root   28 feb 28 04:26 initrd.img -> initrd.img-5.13.0-22-generic
-rw-r--r--  1 root root  40M feb 26 13:55 initrd.img-5.13.0-22-generic
-rw-r--r--  1 root root  37M feb 26 13:54 initrd.img-5.13.19-ubuntu-5.13.0-22.22
-rw-------  1 root root 5,7M nov  5 10:21 System.map-5.13.0-22-generic
-rw-r--r--  1 root root 5,6M feb 26 02:15 System.map-5.13.19-ubuntu-5.13.0-22.22
lrwxrwxrwx  1 root root   25 feb 28 04:27 vmlinuz -> vmlinuz-5.13.0-22-generic
-rw-------  1 root root 9,8M nov  5 13:51 vmlinuz-5.13.0-22-generic
-rw-r--r--  1 root root 8,5M feb 26 02:15 vmlinuz-5.13.19-ubuntu-5.13.0-22.22

Sourcing file /etc/default/grub' Sourcing file/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.13.19-ubuntu-5.13.0-22.22 Found initrd image: /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22 Found linux image: /boot/vmlinuz-5.13.0-22-generic Found initrd image: /boot/initrd.img-5.13.0-22-generic Adding boot menu entry for UEFI Firmware Settings done