27 Nov 2024
A good rule in the slackware wiki about upgrading kernels is to never upgrade
a running kernel. To do that one's /etc/slackpkg/blacklist file would contain
kernel entries like so
kernel-generic.*
kernel-huge.*
kernel-modules.*
kernel-source
Now installing a newer kernel patch becomes a hands-on affair. Here's how we'd do it.
$ mkdir /tmp/slack15
$ cd /tmp/slack15
$ lftp_repo https://slackware.in/slackware/slackware64-15.0/patches/packages/linux-5.15.161/
Here's the lftp_repo script file
#!/bin/sh
lftp -c "open $1 ; mirror -e -c"
This downloads the entire directory linux-5.15.161 from the above mirror. Feel free to substitute with
your mirror and kernel of choice.
Here's how the local copy of the directory should look like
$ ls /tmp/slack15
./ kernel-huge-5.15.161-x86_64-1.txz
../ kernel-huge-5.15.161-x86_64-1.txz.asc
kernel-generic-5.15.161-x86_64-1.txt kernel-modules-5.15.161-x86_64-1.txt
kernel-generic-5.15.161-x86_64-1.txz kernel-modules-5.15.161-x86_64-1.txz
kernel-generic-5.15.161-x86_64-1.txz.asc kernel-modules-5.15.161-x86_64-1.txz.asc
kernel-headers-5.15.161-x86-1.txt kernel-source-5.15.161-noarch-1.txt
kernel-headers-5.15.161-x86-1.txz kernel-source-5.15.161-noarch-1.txz
kernel-headers-5.15.161-x86-1.txz.asc kernel-source-5.15.161-noarch-1.txz.asc
kernel-huge-5.15.161-x86_64-1.txt
$ cd /tmp/slack15
# installpkg *.txz
Make sure you use installpkg. Do not use upgradepkg as it replaces the existing package.
First we generate a new initrd(init ramdisk)
# /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 5.15.161
That should give us the command we'd need to generate the new initrd
# mkinitrd -c -k 5.15.161 -f ext4 -r /dev/lc230vg/root \
-m redacted...:ext4 \
-C /dev/sda3 -L -u \
-o /boot/initrd-5.15.161.gz \
-h /dev/lc230vg/swap
Please note the -o and -h. The -o tells mkinitrd not to overwrite /boot/initrd.gz and the -h is for
specifying the swap partition for hibernating.
If using plain lilo, update /etc/lilo.conf by adding a new image block
image = /boot/vmlinuz-generic-5.15.161
initrd = /boot/initrd-5.15.161.gz
root = /dev/lc230vg/root
label = Linux-5.15.161
read-only # Partitions should be mounted read-only for checking
Then update lilo
# lilo -t
# lilo -v
If using a UEFI machine with elilo, copy over the kernel and initrd to /boot/efi
# cp /boot/initrd-5.15.161.gz /boot/efi/EFI/Slackware/.
# cp /boot/vmlinuz-generic-5.15.161 /boot/efi/EFI/Slackware/.
Update elilo, by adding a new image in /boot/efi/EFI/Slackware/elilo.conf
image=vmlinuz-generic-5.15.161
label=5.15.161
initrd=initrd-5.15.161.gz
read-only
append="root=/dev/mapper/lc230vg-root resume=/dev/mapper/lc230vg-swap vga=normal ro"
Side note: For UEFI machines we don't necessarily need to use the mkinitrd command. Install the kernel patch and then run a
# eliloconfig
This copies the kernel and initrd to the EFI System Partition and then updates elilo.
Reboot and enjoy the new kernel.
Happy Hacking & have a great day!