How to boot RHEL 7 / CentOS 7 to single user runlevel or rescue mode (emergency.target) ?

Starting from RHEL 7 the runlevel concept is no more and now the formerly known as runlevel 1 is

called emergency.target
So we will use the term "emergency.target" for "runlevel 1"

There can be two possible scenarios for going into emergency target level

  • You have a working setup with a shell
  • You machine is unable to boot

Based on the scenario type you can choose the steps to be followed

Scenario 1: When you have a working shell

In this case you can hit the below command to change your existing runlevel to "emergency.target"

You can use below command to switch to rescue mode

[root@golinuxhub ~]# systemctl isolate rescue.target
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.

OR

[root@golinuxhub ~]# systemctl rescue
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.

Broadcast message from root@golinuxhub.lab on pts/1 (Sun 2017-12-24 23:47:08 IST):

The system is going down to rescue mode NOW!

IMPORTANT NOTE: This command is similar to systemctl isolate rescue.target, but it also sends an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the --no-wall command line option:
# systemctl --no-wall rescue

Scenario 2: When you do not have working shell

If you are having boot up related issues then it is obvious that you would want to go to emergency target to get a shell for further troubleshooting the issue
Now with RHEL 7 the steps to switch to emergency.target is completely different from the steps as used in RHEL 6 and earlier variants

Steps to switch runlevel to emergency.target

  • Once the GRUB menu appears during bootup process you will see a splash screen which will contain the list of available kernel for bringing up the system, for my system I only have one kernel installed along with a rescue image
  • Choose the kernel you want to edit using the arrow key to highlight the kernel using which you want to enter into emergency.target
  • then press the letter "e" key to edit the boot entry
Red Hat Enterprise Linux Server (3.10.0-693.el7.x86_64) 7.4 (Maipo)
Red Hat Enterprise Linux Server (0-rescue-d6e5b9fa407542fcbcaa72e7e6b777e2) 7.4 (Maipo)

Use the ^ and v keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt.

The next screen should look similar to the below example of me selecting the 3.10.0-693.el7.x86_64 kernel for editing.

setparams 'Red Hat Enterprise Linux Server (3.10.0-693.el7.x86_64) 7.4 (Maipo)'

        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  af0be92e-0721-46b8-affd-60f9baff3652
        else
          search --no-floppy --fs-uuid --set=root af0be92e-0721-46b8-affd-60f9baff3652
        fi

        linux16 /vmlinuz-3.10.0-693.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet net.ifnames=0 systemd.unit=emergency.target

        initrd16 /initramfs-3.10.0-693.el7.x86_64.img

      Press Ctrl-x to start, Ctrl-c for a command prompt or Escape to   

      discard edits and return to the menu. Pressing Tab lists         
      possible completions.

  • Look  out for line starting with "linux16" on the screen using the arrow button, for some cases it can also be linux and linuxefi
  • Once the blinking cursor is on this respective line press the "End" key from the keyboard to go to the end of this line
  • Give a "blank space" and provide the detail of target you want to boot your system into, for example to boot into emergency target use the below syntax
    systemd.unit=emergency.target

The line should look like below after editing
linux16 /vmlinuz-3.10.0-693.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet net.ifnames=0 systemd.unit=emergency.target
  • Next once done hit "Enter" to save the line
  • Lastly press "Ctrl + x" to boot the system using the changes you have done
  • Next thing you will observe below screen where you must enter "root" user password to continue

  • After giving the password you will get the shell

I hope the article was useful.