update-grub não adiciona todos os kernels ao menu grub

update-grub não adiciona todos os kernels ao menu grub

Ubuntu 21.10.

Estou construindo kernels conforme documentado emhttps://help.ubuntu.com/community/Kernel/Compileehttps://wiki.ubuntu.com/Kernel/BuildYourOwnKernel.

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

Este comando de compilação tem o mesmo resultado:

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

Isso cria alguns .debpacotes:

$ 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

Eu os instalo assim:

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

Este é então o conteúdo de /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

Atualize o initramfs (o que estritamente falando não é necessário porque já foi feito, mas para garantir):

$ 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

Então eu corro 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

Meu kernel compilado 5.13.19-ubuntu-5.13.0-22.22não é adicionado ao menu Grub por update-grub. Eu sei que posso adicioná-lo manualmente, mas há risco de erros de digitação. Também preciso compilar muitos kernels porque estou tentando localizar um possível bug usando o git bisect. O problema do kernel que estou solucionando não ocorre em kernels principais mais recentes, apenas em (alguns, mas não todos) kernels do Ubuntu 21.10, então só faço isso para aprender algo e para satisfazer minha curiosidade.

O que preciso fazer para update-grubadicionar meu kernel compilado do /bootdiretório ao menu Grub?

Responder1

Os três comandos a seguir resolvem esse problema, desativando o bit executável 09_lowlatencye ativando o bit for 10_linux, de acordo com o texto em /etc/grub.d/README.lowlatency.

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

Solução encontrada emhttps://askubuntu.com/a/1228269/149519.

Para confirmar que agora funciona conforme o esperado:

$ 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

informação relacionada