How to recover a system rebooted during an update
Table des matières
Repairing a system rebooted during an update Some actions should never be done during a system update. Rebooting or shutting down the system is one of them. So, what’s more stupid than trying to remove a USB keyboard during the update, except unplug the power cable instead? Yes, I did it, and my machine couldn’t boot afterward… Well, it’s possible to recover without reinstalling everything! The RHEL installation media offers a troubleshooting mode. It can be launched by booting with the media, and choose “Troubleshooting” in the You’ll then see the following screen: Type After a short time, the installation is discovered: As the message said, the system to repair is mounted in If needed, set the keyboard mapping. For example, for a french keyboard: Every time the The error message was about Many other files in this directory are 0 bytes in size. An easy way to fix it is to reinstall the packages. … but only those of the update transaction! Dnf stores the rpm to install in /var/cache/dnf, so, it’s possible to get them and reinstall it using the To use the rpm command without bothering with many options, it’s possible to chroot in the “physical” system. We can do it as the others binaries seems not to be broken: Search for the directories containing the latest transaction: Although only the systemd binaries appear to be broken (the system seemed to be unplugged during the systemd package update), it’s a good idea to reinstall all the packages: the rpm scriptlets and the checks were not run. By reinstalling all the packages, we ensure that all the steps are executed properly. Reinstall all the packages cached for this transaction: Once the packages are reinstalled, reboot the system. The SELinux contexts will be relabeled. It can take some time. The system is working again! 🎉 Note that the console snippets can have typos. I took photos of the screen during the process and used OCR to get the textstarting Switch Root...
[ !! ] Failed to execute /sbin/init
[!!!!!!] Failed to execute fallback shell.
Rebooting in rescue mode
grub menu.Starting installer, one moment...
libreport is not available in this environment - bug reporting disabled
anaconda 40.22.3.26-1.el10_0 for Red Hat Enterprise Linux 10.0 started.
* installation log files are stored in tmp during the installation
* shell is available on TTY2 and in second TMUX pane (ctrl+b, then press 2)
* when reporting a bug add logs from /tmp as separate text/plain attachments
===============================================================================
===============================================================================
Rescue
The rescue environment will now attempt to find your Linux installation and
mount it under the directory : /mnt/sysroot. You can then make any changes
required to your system. Choose '1' to proceed with this step.
You can choose to mount your file systems read-only instead of read-write by
choosing '2'
If for some reason this process does not work choose '3' to skip directly to a
shell
1) Continue
2) Read-only mount
3) Skip to shell
4) Quit (Reboot)
Please make a selection from the above: _
1 and validate by pressing enterRescue Shell
Your system has been mounted under /mnt/sysroot.
If you would like to make the root of your system the root of the active system,
run the command:
chroot /mnt/sysroot
Warning: The rescue shell will trigger SELinux autorelabel on the subsequent
boot. Add "enforcing-0" on the kernel command line for autorelabel to work
properly.
When finished, please exit from the shell and your system will reboot.
Please press ENTER to get a shell:
bash-5.2#
/mnt/sysrootA nice troubleshooting session starts with a pleasant environment
tab key is used to invoke the autocompletion, the buzzer is activated. It’s possible to disable the buzzer totally with the command:
Have a look at what happened
/sbin/init, so let’s examine this file:# ls -l /mnt/sysroot/sbin/init
init is a symbolic link to /lib/systemd/systemd. Let’s list the files in this directory:# ls -l
Reinstalling the packages
rpm command# chroot /mnt/sysroot
# cd /var/cache/dnf
# ls -ltr | grep rpms | tail -n 2
# rpm -Uv --force rhel-9-for-x86_64-baseos-rpms-9ab91850ea154141/* rhel-9-for-x86_64-appstream-rpms-2111d588453ffe4c/*
Reboot
