Boot in single user mode on CentOS 7 / RHEL 7

Profile image of Mattias Geniar

Mattias Geniar, September 28, 2015

Follow me on Twitter as @mattiasgeniar

This guide will show you how to boot into single user mode on a CentOS 7 server. You'll need single user boot to recover a corrupt file system, reset the root password, ...

First, reboot your server and when you enter the Kernel Selection menu, press e to modify the parameters to boot the kernel.

centos7 single user mode 1

The next screen will show you a confusing screen of kernel parameters. It’ll look like this.

centos7 single user mode 2

Scroll down until you find the actual kernel line. It starts with linux16 /vmlinuz-... and will span a couple of lines. You’re now looking for the ro keyword in the kernel linux, which would start the OS with a read only (ro) file system.

centos7 single user mode 3

Use your arrow keys to go to the ro line and replace it with rw init=/sysroot/bin/bash. The result should look like this. If that’s the case, press ctrl+x to boot the kernel with those options.

centos7 single user mode 4

If everything went fine, you’re now in a limited shell with access to the entire filesystem. To make things easier, you can chroot the filesystem so you can access all your known files/directories with the same paths.

centos7 single user mode 5

After you typed chroot /sysroot/, you’ll find your familiar files in /etc, /usr,/var, …

If you’re done working in single user mode, reboot again by pressing ctrl+alt+del.

Update: as a reader pointed out, you may have to remount the filesystem from readonly to read-write, too.

mount -o remount,rw /

After that, you should be able to make changes to files on the disk that persist on reboot.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.