How to upgrade kernels & its assundary other packages WITHOUT removing the old kernels ?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to upgrade kernels & its assundary other packages WITHOUT removing the old kernels ?
Hello All , The subject pretty much describes the dilemna .
ie: How to upgrade kernels & its associated (@GazL was: assundary) other packages WITHOUT removing the old kernels ?
Tia , JimL
Last edited by babydr; 03-15-2022 at 08:19 PM.
Reason: A change , JUst a little too late , already flogged by all the criticism ;-)
Using the command "installpkg" could be a good start. If you use "upgradepkg" then the pŕevious kernel package is going to be removed and replaced by package specified, but the command "installpkg" is not supposed to be remove anything so you will end up having two kernel images installed.
When you do an upgrade-all go over and uncheck kernels, do the upgrade and see if it works. Then do a " slackpkg download kernels.* ", the new kernel will be downloaded, go to the location where the new kernel is located /var/cache/packages/slackware64/a and do a installpkg *.txz. That put the new kernel in the /boot directory copy it to lilo and leave the old one just in case.when you run lilo look for errors.if no errors you will have the old and the new.
This is what I will be doing today to upgrade to kernel 5.16.14 after I run 'slackpkg update', 'slackpkg upgrade-all' (I use slackpkg with slackpkg+):
Code:
# From root.
# Uninstall two programs. This may be overkill but it is what I do based on experiences I have had.
bash /opt/VirtualBox/uninstall.sh
bash /home/non-slack/other/nvidia/NVIDIA-Linux-x86_64-390.147.run --uninstall.
# Now for the kernel.
cd /boot
USEBL=off slackpkg download kernel
# Deselect from the dialog, kernel-firmware, kernel-headers (already installed) and kernel-huge.
installpkg /var/cache/packages/slackware64/*/*.txz
rm /var/cache/packages/slackware64/*/*
mkinitrd -F -k 5.16.13:5.16.14
### Added this, forgot in my original post. I normally use mc to edit the syslink vice ln.
ln -sf vmlinuz-generic-5.16.14 vmlinuz-generic-stock
ln -sf vmlinuz-generic-5.16.13 vmlinuz-generic-working
lilo
reboot
After the reboot, log in as root, install both VirtualBox and the NVIDIA driver again and reboot again. I don't necessarily have to reboot here, but it is what I do.
If interested here is the relative section from my lilo.conf, this setup saves from having to edit lilo every time I install a new kernel, I just change symlinks in /boot/:
This is what I will be doing today to upgrade to kernel 5.16.14 after I run 'slackpkg update', 'slackpkg upgrade-all' (I use slackpkg with slackpkg+):
Code:
# From root.
# Uninstall two programs. This may be overkill but it is what I do based on experiences I have had.
bash /opt/VirtualBox/uninstall.sh
bash /home/non-slack/other/nvidia/NVIDIA-Linux-x86_64-390.147.run --uninstall.
# Now for the kernel.
cd /boot
USEBL=off slackpkg download kernel
# Deselect from the dialog, kernel-firmware, kernel-headers (already installed) and kernel-huge.
installpkg /var/cache/packages/slackware64/*/*.txz
rm /var/cache/packages/slackware64/*/*
mkinitrd -F -k 5.16.13:5.16.14
### Added this, forgot in my original post. I normally use mc to edit the syslink vice ln.
ln -sf vmlinuz-generic-5.16.14 vmlinuz-generic-stock
ln -sf vmlinuz-generic-5.16.13 vmlinuz-generic-working
lilo
reboot
After the reboot, log in as root, install both VirtualBox and the NVIDIA driver and reboot again. I don't necessarily have to reboot here, but it is what I do.
If interested here is the relative section from my lilo.conf:
You should generate a different initrd.gz for each installed kernel, not use the same one for each. The kernel modules inside each initrd.gz needs to be kernel modules of the matching kernel.
My procedure for installing a kernel is this:
*) download the kernel tarball from kernel.org.
*) cd /usr/src
*) tar xvf ~/downloads/linux-5.15.28.tar.xz
*) chown -R root:root linux-5.15.28
*) cd linux-5.15.28
*) make mrproper
*) cp ../linux-5.15.27/.config .
# optional: copy .config from the slackware distribution instead
*) make oldconfig
*) optional:"make menuconfig" and say No to all drivers that you do not need to speed up the compile... this may take some time, so after you do it, you want to reuse your .config from then on; Say Yes to compile-in driver modules for important devices like hard drive controller and network card and any other drivers that might be important for booting. I compile-in all mdraid support, lvm support, fat/ext2/3/4 (filesystems) support etc. ALSA audio is fully (M) modules.
*) make -j6 bzImage
*) make -j6 modules
*) make modules_install
# this installs modules to /lib/modules/5.15.28/
# when removing a kernel, you have to remember to remove /lib/modules/x.y.z also
# when generating initrd.gz for a kernel, it copies certain modules from here
# as you list in mkinitrd.conf (modules that you need to boot and mount / (root), if any).
*) cp -a arch/x86/boot/bzImage /boot/vmlinuz-5.15.28
# this is how to install the kernel itself
*) cp -a System.map /boot/System.map-5.15.28
# this is used for debugging or compiling certain other stuff
*) pico /etc/lilo.config
# I use pico or vi editor
### add a lilo entry for the kernel such as
## default kernel slackware64-15.0
# 5.15.28
image = /boot/vmlinuz-5.15.28
root = /dev/ram0
initrd = /boot/initrd.gz-5.15.28
label = 5.15.28
read-only
###
### each kernel has an entry like this and you can have maybe 9 kernels installed
*) optional: mdadm -Es >> /etc/mdadm.conf
# this is if you have configured mdraid, and you need to have correct ARRAY lines in mdadm.conf.
# this only needs to be done once
*) optional: pico /etc/mkinitrd.conf
# this only needs to be done once...
### set options in mkinitrd.conf such as:
# mkinitrd.conf.sample
# See "man mkinitrd.conf" for details on the syntax of this file
#
#SOURCE_TREE="/boot/initrd-tree"
#CLEAR_TREE="0"
#OUTPUT_IMAGE="/boot/initrd.gz"
#KERNEL_VERSION="$(uname -r)"
#KEYMAP="us"
#MODULE_LIST="ext4"
LUKSDEV="/dev/md1"
#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
ROOTDEV="/dev/cvg1/root"
ROOTFS="ext4"
#RESUMEDEV="/dev/sda2"
RAID="1"
LVM="1"
UDEV="1"
#MODCONF="0"
## load microcode, starting with linux 4.4.110
## to mitigate MELTDOWN and SPECTRE bugs
## The ASUS BIOS 1005 has microcode version 0x4
## Microcode release 20171117 installs version 0x7
## Microcode release 20180108 installs version 0x7 (no update)
MICROCODE_ARCH="/boot/intel-ucode.cpio"
#WAIT="1"
*) optional: install intel-microcode package from slackbuilds.org
*) cd /boot
*) Run mkinitrd... I use a little script "makeinitrd-kernel 5.15.28" for this:
#!/bin/bash
if [[ $1 = "" ]] ; then
echo "Usage: makeinitrd-kernel <kernel version number M.m.p>"
else
( cd /boot ; mkinitrd -F -c -k $1 -s /boot/initrd-tree-$1 -o /boot/initrd.gz-$1 )
fi
#########
/root/bin/makeinitrd-kernel 5.15.28
*) sync
# i tend to run sync to flush disks, just to make sure
*) lilo
# install lilo
My full lilo.conf is
####################
append=" vt.default_utf8=1 "
boot = /dev/md0
lba32
raid-extra-boot = mbr-only
compact
#default = Linux
# Boot BMP Image.
# Bitmap in BMP format: 640x480x8
# bitmap = /boot/slack.bmp
# Menu colors (foreground, background, shadow, highlighted
# foreground, highlighted background, highlighted shadow):
# bmp-colors = 255,0,255,0,255,0
# Location of the option table: location x, location y, number of
# columns, lines per column (max 15), "spill" (this is how many
# entries must be in the first column before the next begins to
# be used. We don't specify it here, as there's just one column.
# bmp-table = 60,6,1,16
# Timer location x, timer location y, foreground color,
# background color, shadow color.
# bmp-timer = 65,27,0,255
# Standard menu.
# Or, you can comment out the bitmap menu above and
# use a boot message with the standard menu:
message = /boot/boot_message.txt
# Wait until the timeout to boot (if commented out, boot the
# first entry immediately):
prompt
# Timeout before the first entry boots.
# This is given in tenths of a second, so 600 for every minute:
timeout = 1200
# Override dangerous defaults that rewrite the partition table:
change-rules
reset
# Normal VGA console
vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# End LILO global section
# Linux bootable partition config begins
#
## notes on mitigations
# Since 4.4.110, we load microcode in initrd, and the kernel
# Linux bootable partition config ends
####################
*) [before rebooting, I uninstall the nvidia driver]
*) reboot
*) [after reboot, install the nvidia driver]
*) [reinstall chrome browser because something is messed up when changing kernels]
To remove a kernel that you are not running anymore (say 5.15.27), you have to remove its entry in lilo, then:
cd /usr/src/
rm -r linux-5.15.27
cd /lib/modules
rm -r 5.15.27
cd /boot
rm vmlinuz-5.15.27 System.map-5.15.27
rm -r initrd-tree-5.15.27
rm initrd.gz-5.15.27
sync
lilo
I think this is everything. Hope that helps.
Last edited by twy; 03-15-2022 at 04:11 AM.
Reason: delete old junk
Forgot to mention: I only install kernel-headers and kernel-firmware packages. The other kernel packages are uninstalled and blacklisted in my /etc/slackpkg/blacklist file. If slackware (Pat) upgrades kernel-headers or kernel-firmware then I upgrade them, otherwise I do not try to upgrade those myself.
A quick and dirty approach would be to just rm /var/lib/pkgtools/packages/kernel-{huge,generic,modules}-$oldversion-* to take it out of package management.
This is particularly useful for the original kernel-modules package that comes with the install dvd. If you ever need to do a recovery by booting from the install-dvd — using root= or chrooting — then it's a good idea to still have present the matching set of kernel modules.
I don't know how slackpkg decides which of two installed same-named packages should be updated when a new package comes along, but my slackscan script will abort if it finds this situation as it's non-interactive and can't ask the user to resolve the ambiguity: so I have to use this approach. Most distro's packaging systems won't allow two packages with the same name to be installed at the same time; Slackware is unusual in that regard.
As the development cycle for 15.0 dragged on I found that I had to upgrade numerous systems to current before the release of 15.0. That was an exercise in repetitious upgrade routines and lots of kernel upgrades on multiple systems.
I adopted a multi-kernel installation approach focused on leveraging slackpkg & slackpkg+. It started as autoslackpkg and now is named slackupdr, a dialog menu driven suite of bash scripts. https://www.go4it2day.com/news/slackupdr-3.2.html
The concept is similar to what others have already shared. Blacklist the kernel generic, huge, modules & source packages for "slackpkg upgrade-all" followed by "slackpkg download kernel" to install the new kernel files, create a new initrd, modify lilo/elilo config files to have access to the old & new kernels, copy new kernel files to the ESP or run lilo.
I use the scripts on all my slackware systems and each system has access to the latest kernel and at least 1 of the previous kernels. I plan to submit slackupdr to SBo when submissions open up.
What is "assundary?" Not listed in dict.org or OED. Do you mean "sundry"?
As opposed to:
"Assundery" (adjective): being positioned below someone's A**
example:
That's one assundery chair.
Nope. "Sundry" would not be correct in this context either as it implies an indeterminate number of non-specific objects of unspecified relation, which is not the case here as the kernel related components are: of a known quantity, specific, and related (or at the very least associated).
I'd suggest "related" or perhaps "associated" would have been more correct if we're going to be pedantic about it.
Very interesting, reading the many ways to do this above.
I use a backup/restore kernel management script that preserves a "user specified" number of previous, recent kernels - while deleting the old ones. Works seamlessly with slackpkg without the need to blacklist anything or have multiple kernel version packages installed. Can/should be run 'dry' for the initial backup and will accumulate kernels after running for each kernel update until the MAX is reached.
I'm still testing and tweaking it, but it's working well so far on four machines running current & 15.0 stable. Tested and works with minor kernel series change (attached)
It's set for Grub2 & creating versioned initrd's (I use Richard Cranium's grub2 script). Adapting it to lilo/elilo should be straight forward (although you may need to watch your space on the ESP partition with elilo)
If anyone wants to try it out, please see below. However, be warned... (use at your own risk!!!) If I butchered anything (wouldn't be the first time), please let me know.
Code:
#!/bin/bash
# Kernel Upgrade Backup & Restore Script by truepatriot76, in an effort to preserve what slackpkg discards
# when upgrading the kernel packages
VER=$(echo `find /boot/ -type f -iname vmlinuz* | sort -V | tail -n 1` | awk -F- '{print $NF}')
CWV=`uname -r`
MAX=10 #Maximum number of kernels to store
# Create kernel backup directory
if [ -d "/root/tmp-kernel" ]; then
echo "Kernel backup directory exists"
else
mkdir /root/tmp-kernel/
fi
# Sanity check
if [ $MAX -lt 2 ]; then
echo "This is not the script for you"
exit
fi
# Check if current running kernel has an update pending
if [ $VER = $CWV ]; then
echo "No kernels to process"
if [ -d "/root/tmp-kernel/$VER" ]; then
echo "Backup module directory exists"
else
cp -fR /lib/modules/$VER/ /root/tmp-kernel/
fi
if [ -s "/root/tmp-kernel/System.map-generic-$VER" ]; then
echo "Backup System.map exists"
else
cp /boot/System.map*$VER /root/tmp-kernel/
fi
if [ -s "/root/tmp-kernel/config-generic-$VER.x64" ]; then
echo "Backup kernel config exists"
else
cp /boot/config*$VER* /root/tmp-kernel/
fi
if [ -s "/root/tmp-kernel/vmlinuz-generic-$VER" ]; then
echo "Backup kernels exist"
else
cp /boot/vmlinuz*$VER /root/tmp-kernel/
fi
if [ -s "/boot/initrd-$VER.gz" ]; then
echo "Versioned initrd exist"
else
$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -k $VER -r -a "-o /boot/initrd-$VER.gz")
fi
exit
fi
# restore and backup kernel files and modules
mv /root/tmp-kernel/$CWV/ /lib/modules/
mv /root/tmp-kernel/* /boot/
cp -fR /lib/modules/$VER/ /root/tmp-kernel/
cp /boot/System.map*$VER /root/tmp-kernel/
cp /boot/config*$VER* /root/tmp-kernel/
cp /boot/vmlinuz*$VER /root/tmp-kernel/
# delete oldest version if number of kernels exceeds max
NUM=`find /boot/ -type f -iname vmlinuz-generic* | wc -l`
while [ $NUM -gt $MAX ]; do
DELVER=`find /boot/ -type f -iname vmlinuz* | sort -V | head -n 1`
DELVER=${DELVER#*-}
DELVER=${DELVER#*-}
echo "Deleting oldest kernel $DELVER ..."
rm -fR /lib/modules/$DELVER
rm /boot/*$DELVER*
NUM=`find /boot/ -type f -iname vmlinuz-generic* | wc -l`
done
# create versioned initrd
$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -k $VER -r -a "-o /boot/initrd-$VER.gz")
# update grub
grub-mkconfig -o /boot/grub/grub.cfg
Last edited by truepatriot76; 03-16-2022 at 01:37 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.