Recover CentOS 8 who fell into the darkness of the infinite restart loop in single user mode

What did you do

  1. Restart CentOS every night in the middle of the night!
  2. Let's do regular execution with "Make your own systemd"!

image.png

Well! !!

↓ This was no good. ** Create and enable systemd (service) for restart Yoshi! ** **

Something like the following ...

Reboot ↓ Reboot systemd (service) will be executed ↓ Reboot ↓ Reboot systemd (service) will be executed ↓ ...... It has become an infinite loop of restarting ... (´ ・ ω ・ `)

** The service that was activated as soon as it started started running ** was out of my mind.

Then what to do

Linux has a ** single-user mode **. Since it starts with the minimum configuration, you can recover when it is (no ∀`) like this time.

It feels like a feature similar to ** BIOS ** or ** Windows Safe Mode **.

However, single-user mode cannot be over the network. I have to walk tech-tech with my feet to the front of the machine and operate it directly ...

How to start single user mode

First, press `` `e``` when the screen below appears. image.png Then, the screen looks like this. image.png

rd after rhgb quiet.Enter break.


 ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/706116/460bdbf4-bd55-7ba5-f451-5241f1596ad8.png)
 Then you can start single user mode with Ctl + x!

# Remount sysroot to work with files
 The purpose of this time is ** to fix the wrong shell script file **, so you need to bring the file ready for operation.
 Then remount sysroot.

 The following command.


#### **`python`**
```sh

mount -o remount,rw /sysroot
chroot /sysroot

The following is the state where I remounted and tried to ls -l. image.png At this point, it is almost the same as ** Starting CentOS8 and opening the terminal **, so you can modify the file with vi or something.

After modifying the file, I did `` `exit``` twice and CentOS8 started up safely. (Twice exit from remounted sysroot and exit from single user mode)

Serpentine

This time it was my physical server so I managed to do it, but what if something similar happens on AWS?

When migrating to the cloud, let's check if there is a single-user mode recovery method ...

Reference site

https://rin-ka.net/centos-7-8-single-mode-how-to/

version

CentOS Linux release 8.3.2011

Recommended Posts

Recover CentOS 8 who fell into the darkness of the infinite restart loop in single user mode
Step into the darkness of msync