Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the three ways to start CentOS/RHEL 7 Compact 8 in single user mode

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces in detail the corresponding analysis and solutions to the three ways to start CentOS/RHEL 7Compact 8 in single-user mode, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Single-user mode, also known as maintenance mode, allows superusers to recover / fix system problems.

In general, such problems cannot be fixed in a multi-user environment. The system can be started but the function doesn't work properly or you can't log in to the system.

In systems based on Red Hat (RHEL) 7 amp 8, it is implemented using runlevel1.target or rescue.target.

In this mode, all local file systems are mounted, but the network interface is not enabled.

The system starts only a few specific services and fixes as few functions as possible.

This is useful when you want to run a file system consistency check to repair a corrupted file system, or to reset your password after forgetting your root password, or when you want to fix a mount point problem on your system.

Method 1

Start the CentOS/RHEL 7 rd.break 8 system in single-user mode by adding a parameter to the kernel.

Restart your system, in the GRUB2 startup interface, press the e key to edit the selected kernel. You need to select the first row, the first is the latest kernel, however, if you want to boot the system with the old kernel, you can also choose other rows.

Depending on your RHEL/CentOS version, find the linux16 or linux statement, press the End key on the keyboard, skip to the end of the line, add the keyword rd.break as shown in the screenshot below, and press Ctrl+x or F10 to enter single-user mode.

If your system is RHEL/CentOS 7, you need to find linux16, if your system is RHEL/CentOS 8, then you need to find linux.

This change will cause your root file system to be mounted in "ro" mode. You can verify it with the following command. The following output also clearly tells you that you are currently in "emergency mode Emergency Mode".

# mount | grep root

In order to modify the sysroot file system, you need to remount it in read-write mode (rw).

# mount-o remount,rw / sysroot

Run the following command to modify the environment, which is known as the "incarceration directory" or "chroot prison".

# chroot / sysroot

Now, single-user mode is completely ready. When you fix your problem and want to exit single-user mode, perform the following steps.

CentOS/RHEL 7 use 8 uses SELinux by default, so create the following hidden file, which will re-mark all files the next time you start.

# touch /. Autorelabel

Finally, restart the system with the following command. You can also restart your system by typing the exit command twice.

# reboot-f method 2

Start the CentOS/RHEL 7and8 system in single-user mode by replacing the rhgb quiet statement in the kernel with init=/bin/bash or init=/bin/sh.

Restart your system, in the GRUB2 startup interface, press the e key to edit the selected kernel.

Find the statement rhgb quiet, replace it with init=/bin/bash or init=/bin/sh, and press Ctrl+x or F10 to enter single-user mode.

Screenshot of init=/bin/bash.

Screenshot of init=/bin/sh.

By default, the above operation will mount your / partition in read-only (ro) mode, so you need to remount / file system in read-write (rw) mode so that you can modify it.

# mount-o remount,rw /

Now you can carry out your mission. When finished, execute the following command to turn on the SELinux relabel on restart.

# touch /. Autorelabel

Finally, restart the system.

# exec / sbin/init 6 method 3

Start the CentOS/RHEL 7 ro 8 system in single-user mode by replacing the ro word in the kernel with the CentOS/RHEL parameter.

To interrupt the automatic startup process, restart your system and press any key in the GRUB2 startup interface.

Now show all the available kernels on your system, select the latest kernel, and press the e key to edit the selected kernel parameters.

Find the statement that starts with linux or linux16 and replace ro with rw init=/sysroot/bin/sh. Press Ctrl+x or F10 to enter single-user mode after replacement.

Run the following command to change the environment to "chroot Prison".

# chroot / sysroot

If necessary, make the necessary changes. After the modification, execute the following command to turn on the SELinux relabeling on restart.

# touch /. Autorelabel

Finally, restart the system.

# reboot-f this is the answer to the question about how to start CentOS/RHEL 7 gambit 8 in single-user mode. I hope the above content can be of some help to you. If you still have a lot of questions to solve, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report