Background#
In the morning, I turned on my computer and decided to update the system in Terminal since it had been a while. There were many packages to update, so I opened the browser to do other things while the update was in progress. However, after only two minutes, the computer suddenly went black... There was no response, but I could hear the computer still running. Without thinking much, I decided to force shutdown. But when I tried to restart the computer and entered the grub interface, it just froze (usually it automatically selects after 5 seconds). I manually selected and received the following prompt:
Loading kernel linux-zen
error: file '/boot/vmlinuz-linux-zen' not found
Loading initial ramdisk
error: you need to load the kernel first
Press any key to continue...
I guessed that the problem was caused by the forced shutdown during the kernel update. I found some solutions on the Arch Linux BBS, and I will record them here.
Note
I am using the linux-zen
kernel, so the following content has the -zen
suffix. You can change it according to your own configuration. Generally, the installed kernel is linux
, so you can remove the -zen
suffix.
Solutions#
Using Arch Linux installation media#
- After entering the live environment, connect to the network. I am using iwd.
[root@archiso]# iwctl
[iwd]# station wlan0 connect wifi-ssid # Connect to the specified Wi-Fi
[iwd]# station wlan0 show # Confirm if the connection is successful
[iwd]# exit
- Mount the
/
andboot
partitions.
mount /dev/sdaX /mnt
mount /dev/sdaY /mnt/boot
- Chroot into the system and reinstall the kernel.
arch-chroot /mnt
pacman -S linux-zen
- Regenerate the grub bootloader.
grub-mkconfig -o /boot/grub/grug.cfg
- Unmount the partitions and reboot.
exit
umount -R /mnt
reboot
After the restart, you should be able to enter the system normally.
grub command line#
This method is similar to the previous one, but it does not require the use of installation media.
Confirm the /
partition location#
- Use
ls
to list all the disks on the computer. The output will be similar to:
grub>ls
(hd0) (hd0, gpt1) ...... (hd1, gpt4)
- Confirm the
/
partition by using thecat
/ls
command +Tab
to test. For example:
grub>ls (hd0,gpt3)/ TAB
boot usr ....
The above output indicates that (hd0,gpt3)
is the /
partition.
Manually load the kernel#
- Set the root partition and grub prefix path. Assuming
(hd0,gpt3)
is the root partition:
grub>set root=(hd0,gpt3)
grub>set prefix=(hd0,gpt3)/boot/grub
- Load the kernel and system image.
grub>cat (hd0,gpt3)/boot/grub/grub.cfg # Confirm the device name of the `/` partition, assuming it is `/dev/sda3`
grub>linux /boot/vmlinuz-linux-zen root=/dev/sda3
grub>initrd /boot/initrd-linux-zen.img
- Start the system.
grub>boot
- Reconfigure grub.
After booting, follow steps 2, 4, and 5 of the first method to regenerate the grub.cfg file in the command line.
Reference Links#
https://bbs.archlinux.org/viewtopic.php?id=274616
https://wiki.archlinux.org/title/GRUB#Using_the_command_shell