2

In the rare cases that a RHEL or CentOS 6 system is prevented from booting by (for instance) an improper shutdown, or a forced fsck-check failure on boot, the console will prompt the user for a root password.

How do I disable the password check and drop directly to a root-shell?

Unacceptable answers:

  • overriding init on kernel command line (ie, grub)
  • linking / replacing /sbin/sulogin with /sbin/sushell. (This would work, but it would raise red flags with the security framework).
  • booting from some other device
  • Many rc faults will invoke rcS-emergency, and adding EMERGENCY=/bin/sushell to /etc/sysconfig/init will make it run sushell. I don't know if this covers every conceivable fault that rc stuff can run into, though. – Mark Plotnick Jul 21 '15 at 19:30
  • Ah, so the "environment" from rcS-emergency comes from /etc/sysconfig/init? Post that as an aswer; I will test and accept. – Otheus Jul 22 '15 at 13:39
1

At several points in rc.sysinit, rcS-emergency will be run when there's a problem requiring administrator intervention, such as:

echo $"*** An error occurred during the file system check."
echo $"*** Dropping you to a shell; the system will reboot"
echo $"*** when you leave the shell."
str=$"(Repair filesystem)"
PS1="$str \# # "; export PS1
[ "$SELINUX_STATE" = "1" ] && disable_selinux
start rcS-emergency

Here is the rcS-emergency script:

. /etc/sysconfig/init
plymouth --hide-splash || true
[ -z "$EMERGENCY" ] && EMERGENCY=/sbin/sulogin
exec $EMERGENCY

If you add EMERGENCY=/bin/sushell to /etc/sysconfig/init, it'll run sushell, which doesn't ask for a password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.