Original link: https://blog.phoenixlzx.com/2022/06/06/rescue-broken-centos-systemd-timeout/
It’s time to help people repair the system.
According to the description of the situation is “stuck at ‘Starting switch root'”, the preliminary judgment is that the initramfs is broken. After inquiring, sure enough, a guy who loves to update when he has nothing to do was pressed by the mentally retarded remote hand in the data center during the update ¯(ツ)/¯
Since it can’t be started, enter Rescue. Although the CentOS system is not very good, at least the original ISO provides the option of Rescue, and it can also automatically find the root partition to mount. I thought it was a trivial matter, but when I was preparing to chroot, the sentence “chroot: cannot run command `/bin/sh’: Exec format error” suddenly popped up, and I was instantly heartbroken $#%#$^$#@#%#
In general, the error “Exec format error” indicates a binary format error, such as executing a 64-bit binary on a 32-bit system. But this is impossible. First of all, it is also the x86_64 architecture, the installed system and the ISO system are also the same version, and the disk does not report an error. Why does this problem occur?
The possibility of the file being written bad due to the power failure during the update is not impossible, but the strange thing is that the same error is reported when executing /bin/bash
. It’s so bad that I’m afraid that glibc is not hanging…? But in a word, the first step is to be able to advance the system to see what is going on, so I am hesitant and directly overwrite the corresponding directory on the disk with /usr
of the Live CD.
1 |
~> cp -r /usr /m nt /sysimage/ |
Then chroot again, and you can successfully enter the system, and the yum
command can also be used. Since the power outage is during the update process, you should try to repair the incomplete update first.
1 |
~> yum-complete-transaction |
Ahh.
1 |
~> yum update |
…It really is.
Further understanding that this system does not install 32-bit packages, so where does this 32-bit glibc come from? yum check
to no avail, not to mention a weird kbd package that doesn’t even have anything to do with 32-bit. It seems that the bad is not light, but since it is determined that there is no 32-bit package in the system, then you can continue to the end.
1 |
# complete all unupdated packages |
One operation is as fierce as a tiger. When reinstalling all the packages for the first time, an error will be reported in ldconfig. Some libraries are empty files, and the error will not be seen after the second complete reinstallation. It seems feasible, restart decisively, and see the login prompt after a bunch of OK.
1 |
localhost login : root |
hmmmm? ? ? I haven’t entered my password yet? ? ?
An error is reported without entering the password, at least it is not a problem with PAM. What about before that? It should be systemd-logind. Fortunately, the network can be started normally, and SSH can log into the system normally. If the network or SSH does not work, then you have to enter the rescue again.
Many underlying services that should have been in the system have not been started, such as systemd-logind. I want to check the status of this product, but the result is an error:
1 |
Failed to activate service 'org.freedesktop.systemd1' : timed out |
Huh? systemd itself did not start normally, look at the log:
1 |
... |
Not lightly ill. These file contents are gone, and repackaging doesn’t overwrite them. Had to override it manually.
1 |
# Install necessary tools |
So get the contents of these packages. Manually overwrite all files in the etc/dbus-1
directory to the file system, and then execute kill 1
1 |
localhost systemd[1]: Received SIGTERM from PID 4332 (bash). |
Check it carefully, all kinds of services are starting normally!
(๑•̀ㅂ•́)و✧
Postscript: Don’t worry about updating the production system.
Postscript 2: There is no reliable remote data center in Western countries.
This article is reprinted from: https://blog.phoenixlzx.com/2022/06/06/rescue-broken-centos-systemd-timeout/
This site is for inclusion only, and the copyright belongs to the original author.