8

My laptop lost battery during an update, so the linux kernel got truncated. After arch-chrooting into it and reinstalling linux, it's OK, but /boot/initramfs-linux.img (and the fallback) are empty. Also, /etc/mkinitcpio.d/linux.preset is empty. How can I fix this, and how can I generate a preset?

ls /etc/mkinitcpio.d/ returns nothing

R Harrington
  • 213
  • 1
  • 2
  • 8

2 Answers2

8

Had this recently. My solution was to chroot into the system from an Arch live system. Delete the empty linux.preset in /etc/mkinitcpio.d/ and then run pacman -S linux.

This regenerated the linux.preset and the initramfs was rebuild. After that Arch booted as usual.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
MeisterGlanz
  • 81
  • 1
  • 2
4

Regenerate a new initramfs-linux.img accordingly to the archlinux wiki:

mkinitcpio -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img -k 5.5.7-arch1-1

use ls /usr/lib/modules to get the available kernel.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
  • I just get `/usr/sbin/mkinitcpio: line 265: /etc/mkinitcpio.d/linux.preset: No such file or directory ==> ERROR: Failed to load preset: /etc/mkinitcpio.d/linux.preset'` on the second command – R Harrington Mar 04 '20 at 18:08
  • Yes, it's installed and I've reinstalled it – R Harrington Mar 04 '20 at 18:13
  • @RHarrington could you add the `ls /etc/mkinitcpio.d/` – GAD3R Mar 04 '20 at 18:18
  • @RHarrington See my edit please. – GAD3R Mar 04 '20 at 18:57
  • I'm chrooted in, so I get `==> ERROR: '/lib/modules/5.1.0-050100-generic' is not a valid kernel module directory ` because of my host's kernel. How can I fix this? – R Harrington Mar 04 '20 at 19:13
  • 1
    @RHarrington see https://unix.stackexchange.com/questions/395402/lib-modules-4-9-8-1-arch-is-not-a-valid-kernel-module-directory – GAD3R Mar 04 '20 at 19:18
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/105171/discussion-between-r-harrington-and-gad3r). – R Harrington Mar 04 '20 at 19:34
  • Down-voted as this is not a permanent fix. You'll have to do this manually every time you upgrade linux. The other answer is a permanent fix. – Gary van der Merwe Nov 14 '21 at 16:53
  • @GaryvanderMerwe downvote is used for the wrong answer, not for the accepted answer. – GAD3R Nov 14 '21 at 17:51