====== Old Kernel Cleaup ======
[[https://www.youtube.com/watch?v=uCR_CdNCVlQ]]
===== Bakup GRUB and initrd =====
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
cp /boot/initrd.gz /boot/initrd.gz.bak
===== Removing old kernel packages =====
// First list packages to delete //
ls /var/log/packages/kernel-*-5.15.193*
// Then run removepkg command //
removepkg /var/log/packages/kernel-huge-5.15.193-x86_64-1
removepkg /var/log/packages/kernel-generic-5.15.193-x86_64-1
removepkg /var/log/packages/kernel-modules-5.15.193-x86_64-1
removepkg /var/log/packages/kernel-source-5.15.193-noarch-1
//Do not remove kernel headers because if we'll remove kernel-headers by removepkg command we delete key system directories f.e. for script compiling so system would start but we wouldn't be able to compile any package, even simple console program//
Then check does removepkg command cleaned all old kernel symlinks and folders. If not delete them manually:
cd /boot
rm -f config-generic-5.15.193.x64 config-huge-5.15.193.x64
rm -f System.map-generic-5.15.193 System.map-huge-5.15.193
rm -f vmlinuz-generic-5.15.193 vmlinuz-huge-5.15.193
rm -rf /usr/src/linux-5.15.193
===== Setting up new main kernel =====
cd /boot
ln -sf vmlinuz-6.18.8 vmlinuz
ln -sf System.map-6.18.8 System.map
ln -sf .config-6.18.8 config
===== Generate new GRUB config =====
grub-mkconfig -o /boot/grub/grub.cfg