💾 Archived View for pwshnotes.flounder.online › gemlog › 2022-12-24-manjaro-old-kernel.gmi captured on 2024-02-05 at 09:31:50. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Cleaning Up an Old Kernel in Manjaro

I was updating Manjaro and received the following errors:

(11/23) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux515.preset: 'default'
  -> -k /boot/vmlinuz-5.15-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.15-x86_64.img
==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-5.15-x86_64'
==> Building image from preset: /etc/mkinitcpio.d/linux515.preset: 'fallback'
  -> -k /boot/vmlinuz-5.15-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.15-x86_64-fallback.img -S autodetect
==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-5.15-x86_64'

Previously, I installed the Linux 5.15 kernel to troubleshoot an unrelated issue. And I uninstalled 5.15 using the "Kernel" applet within the Manjaro Settings Manager. It seems like one of the uninstallation scripts did work correctly because I've had two issues since then. One, I still had the option to boot 5.15 from GRUB. So the boot menu was not updated. Two, I noticed the error above while updating Manjaro.

I'm not familiar with the GRUB bootloader. And I did not see clear instructions for fixing the boot menu. So, I installed and uninstalled the 5.15 kernel again. That fixed the boot menu at the cost of downloading the 5.15 kernel.

Below are the steps to address the "specified kernel image does not exist" error from the pacman output (Manjaro update).

Specified Kernel Image Does Not Exist

To begin my troubleshooting, I noticed the error refers to the file "/etc/mkinitcpio.d/linux515.preset". So, I opened a shell and looked at the parent directory to see what was there.

PowerShell 7.3.1
> Set-Location /etc/mkinitcpio.d/   
> Get-ChildItem

   Directory: /etc/mkinitcpio.d

UnixMode   User Group    LastWriteTime Size Name
--------   ---- -----    ------------- ---- ----
-rw-r--r-- root root    9/4/2021 12:26  396 linux513.preset.pacsave
-rw-r--r-- root root  12/23/2021 11:06  396 linux515.preset
-rw-r--r-- root root   4/15/2022 03:59  396 linux517.preset.pacsave
-rw-r--r-- root root   6/15/2022 17:01  396 linux518.preset.pacsave
-rw-r--r-- root root    8/8/2022 00:54  396 linux519.preset.pacsave
-rw-r--r-- root root  10/10/2022 19:59  392 linux60.preset
-rw-r--r-- root root  12/20/2022 15:19  395 linux61.preset

That shows me the file exists:

-rw-r--r-- root root  12/23/2021 11:06  396 linux515.preset

This listing also shows me that one preset is created for each version of the kernel that was installed.

I recognize linux60 and linux61 as the two kernels I have installed now.

I also noticed that some of the presets have an additional ".pacsave" file extension. And those files correspond to kernels I uninstalled. So, for example, I used to have Linux 5.17 installed, and now I see the "linux517.preset.pacsave" file.

I'm not familiar with the "/etc/mkinitcpio.d/" directory. So, I searched the Manjaro forum for more information.

I found a thread that said:

Check what you got under /usr/lib/modules. If there are no linux## folders there then you can remove related files in /boot and /etc/mkinitcpio.d manually. Otherwise, you need to uninstall the linux package with pacman.

This seemed like good information.

Also, further down, someone mentioned "sudo mhwd-kernel -li" as a way to list the installed kernels. I have not used the mhwd-kernel command before. And I thought this was worth running.

PowerShell 7.3.1
> # Check /usr/lib/modules. 
> Get-ChildItem /usr/lib/modules

   Directory: /usr/lib/modules

UnixMode   User Group    LastWriteTime Size Name
--------   ---- -----    ------------- ---- ----
drwxr-xr-x root root  12/24/2022 01:30 4096 6.0.15-1-MANJARO
drwxr-xr-x root root  12/20/2022 15:19 4096 6.1.0-1-MANJARO
drwxr-xr-x root root  12/24/2022 01:30 4096 6.1.1-1-MANJARO
drwxr-xr-x root root  12/24/2022 01:30 4096 extramodules-6.0-MANJARO
drwxr-xr-x root root  12/24/2022 01:30 4096 extramodules-6.1-MANJARO

> # I don't see any kernel 5.15 files in /usr/lib/modules 
> # So, it is ok to remove any 5.15 files from /boot and /etc/mkinitcpio.d


> # Remove related files in /boot. 
> Get-ChildItem /boot

   Directory: /boot

UnixMode   User Group    LastWriteTime     Size Name
--------   ---- -----    -------------     ---- ----
drwxr-xr-x root root  12/24/2022 01:31     4096 grub
drwxr-xr-x root root  11/14/2022 09:34     4096 memtest86+
-rw------- root root  12/24/2022 01:30 38851001 initramfs-6.0-x86_64-fallback.img
-rw------- root root  12/24/2022 01:30  9116804 initramfs-6.0-x86_64.img
-rw------- root root  12/24/2022 01:31 39141988 initramfs-6.1-x86_64-fallback.img
-rw------- root root  12/24/2022 01:30  9116633 initramfs-6.1-x86_64.img
-rw-r--r-- root root   11/8/2022 13:02  5678080 intel-ucode.img
-rw-r--r-- root root  12/21/2022 15:13       21 linux60-x86_64.kver
-rw-r--r-- root root  12/21/2022 15:26       20 linux61-x86_64.kver
-rw-r--r-- root root  12/24/2022 01:30 11136192 vmlinuz-6.0-x86_64
-rw-r--r-- root root  12/24/2022 01:30 11178848 vmlinuz-6.1-x86_64

> # I don't see any 5.15 files in /boot
> # There is nothing to do in the /boot directory. 


> # Check the mhwd-kernel -li output. 
> sudo mhwd-kernel -li
[sudo] password for michael: 
Currently running: 6.1.0-1-MANJARO (linux61)
The following kernels are installed in your system:
   * linux60
   * linux61

> # Only Linux 6.0 and Linux 6.1 show which are the kernels I recognize as installed. 

At this point I've followed the advice I found. And I did not find any Linux 5.15 files under /usr/lib/modules or /boot.

The advice says to remove the linux515.preset file.

But, the original poster points out that other kernels use the .pacsave extension to signify that they are uninstalled. And it seemed like a good idea to follow this pattern.

I agree.

So, I also renamed my linux515.preset file to "linux515.preset.pacsave"

Note that I give myself a root shell so my PowerShell cmdlets work: sudo -k pwsh The trade-off is I lose the logging sudo would normally do for each command.

PowerShell 7.3.1
> sudo -k pwsh
[sudo] password for michael: 


PowerShell 7.3.1
PS /etc/mkinitcpio.d# Set-Location /etc/mkinitcpio.d/
PS /etc/mkinitcpio.d# Get-ChildItem
   Directory: /etc/mkinitcpio.d

UnixMode   User Group    LastWriteTime Size Name
--------   ---- -----    ------------- ---- ----
-rw-r--r-- root root    9/4/2021 12:26  396 linux513.preset.pacsave
-rw-r--r-- root root  12/23/2021 11:06  396 linux515.preset
-rw-r--r-- root root   4/15/2022 03:59  396 linux517.preset.pacsave
-rw-r--r-- root root   6/15/2022 17:01  396 linux518.preset.pacsave
-rw-r--r-- root root    8/8/2022 00:54  396 linux519.preset.pacsave
-rw-r--r-- root root  10/10/2022 19:59  392 linux60.preset
-rw-r--r-- root root  12/20/2022 15:19  395 linux61.preset


PS /etc/mkinitcpio.d# # Rename linux515.preset
PS /etc/mkinitcpio.d# Move-Item ./linux515.preset ./linux515.preset.pacsave
PS /etc/mkinitcpio.d# Get-ChildItem

   Directory: /etc/mkinitcpio.d

UnixMode   User Group    LastWriteTime Size Name
--------   ---- -----    ------------- ---- ----
-rw-r--r-- root root    9/4/2021 12:26  396 linux513.preset.pacsave
-rw-r--r-- root root  12/23/2021 11:06  396 linux515.preset.pacsave
-rw-r--r-- root root   4/15/2022 03:59  396 linux517.preset.pacsave
-rw-r--r-- root root   6/15/2022 17:01  396 linux518.preset.pacsave
-rw-r--r-- root root    8/8/2022 00:54  396 linux519.preset.pacsave
-rw-r--r-- root root  10/10/2022 19:59  392 linux60.preset
-rw-r--r-- root root  12/20/2022 15:19  395 linux61.preset

PS /etc/mkinitcpio.d# 

Since this issue only occurs during an update, I don't have a convenient way to test this change. The next time I update my computer, I will come back here and report the result.

References

Mkinitcpio tries to work on uninstalled kernels - Support - Manjaro Linux Forum

A Short Introduction | Sudo

Created: Saturday, December 24, 2022

Updated: Saturday, December 24, 2022