Skip to content

Installation of kernel from deb package (Ubuntu)

Kevin Doren edited this page Oct 2, 2021 · 12 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) In this example, KERN=5.10.59-rt51-v7l+

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

apt install ./linux-image-5.10.59-rt51-v7l+_5.10.59-1_armhf.deb

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

KERN=5.10.59-rt51-v7l+

Then run the following commands (copy and paste the entire block). This will replace the entire file config.txt, for installing an alternate kernel on stock Ubuntu system. For installing a 2nd alternate kernel, hand editing of config.txt will be required.

mkdir -p /boot/firmware/$KERN/overlays/
cp -d /usr/lib/linux-image-$KERN/overlays/* /boot/firmware/$KERN/overlays/
cp -dr /usr/lib/linux-image-$KERN/* /boot/firmware/$KERN/
[[ -d /usr/lib/linux-image-$KERN/broadcom ]] && cp -d /usr/lib/linux-image-$KERN/broadcom/* /boot/firmware/$KERN/
touch /boot/firmware/$KERN/overlays/README
cp /boot/vmlinuz-$KERN /boot/firmware/$KERN/
cp /boot/System.map-$KERN /boot/firmware/$KERN/
cp /boot/config-$KERN /boot/firmware/$KERN/
cp /boot/initrd.img-$KERN /boot/firmware/$KERN/
cp /boot/firmware/config.txt{,.bak}
cat > /boot/firmware/config.txt << EOF
# Please DO NOT modify this file; if you need to modify the boot config, the
# "usercfg.txt" file is the place to include user changes. Please refer to
# the README file for a description of the various configuration files on
# the boot partition.

[pi4]
max_framebuffers=2
[all]

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

[none]
# pi4 stock kernel
kernel=uboot_rpi_4_32b.bin
device_tree_address=0x03000000
[all]

# The following settings are "defaults" expected to be overridden by the
# included configuration. The only reason they are included is, again, to
# support old firmwares which don't understand the "include" command.

enable_uart=1
cmdline=cmdline.txt

include syscfg.txt
include usercfg.txt

EOF

Then reboot.

$ uname -a
Linux ubuntu 5.10.59-rt51-v7l+ #1 SMP PREEMPT_RT Fri Aug 20 20:28:57 PDT 2021 armv7l armv7l 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.

Clone this wiki locally