Skip to content

Installation of kernel from deb package (Raspberry Pi OS)

Kevin Doren edited this page Feb 14, 2022 · 21 revisions

We'll need to first install the desired deb package using apt, then set the bash variable KERN to the release being installed. The instructions below are all run as root ("sudo su" to become root)

If installing a 64-bit kernel on a 32-bit system, first see 64-bit-kernel-with-32-bit-userland

To install from .deb package, first install the desired linux-image deb package file (change as appropriate):

apt install ./linux-image-5.10.73-rt54-v7l+_5.10.73-1_armhf.deb     # 32-bit kernel
apt install ./linux-image-5.10.73-rt54-v8+_5.10.73-1_arm64.deb      # 64-bit kernel

Then set bash variable KERN to the release being installed (change as appropriate):

KERN=5.10.73-rt54-v7l+   # 32-bit kernel
KERN=5.10.73-rt54-v8+    # 64-bit kernel

Then run the following commands (copy and paste the entire block):

mkdir -p /boot/$KERN/overlays/
cp -d /usr/lib/linux-image-$KERN/overlays/* /boot/$KERN/overlays/
cp -dr /usr/lib/linux-image-$KERN/* /boot/$KERN/
[[ -d /usr/lib/linux-image-$KERN/broadcom ]] && cp -d /usr/lib/linux-image-$KERN/broadcom/* /boot/$KERN/
touch /boot/$KERN/overlays/README
mv /boot/vmlinuz-$KERN /boot/$KERN/
mv /boot/initrd.img-$KERN /boot/$KERN/
mv /boot/System.map-$KERN /boot/$KERN/
cp /boot/config-$KERN /boot/$KERN/
cat >> /boot/config.txt << EOF

[all]
kernel=vmlinuz-$KERN
# initramfs initrd.img-$KERN
os_prefix=$KERN/
overlay_prefix=overlays/$(if [[ "$KERN" =~ 'v8' ]]; then echo -e "\narm_64bit=1"; fi)
[all]
EOF

Then reboot.

$ uname -a
Linux jambox 5.10.73-rt54-v7l+ #1 SMP PREEMPT_RT Sat Oct 16 09:13:55 PDT 2021 armv7l GNU/Linux

multiple kernels, including both 32-bit and 64-bit can be installed on a 32-bit system. In that case, in config.txt, change [all] to [none] at beginning of config.txt section for all but the desired boot kernel.