sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: StartupShutdown III
module list

Common Problems in RH7

Just like with grub1, most emergency problems in RH7 require booting to single-user mode. This involves changing the default target for systemd at boot time.

Changing systemd's default target at boot

During a normal boot, systemd's target is default.target. This is linked by a systemctl command to one of the two standard targets - multi-user.target or graphical.target via the systemctl set-default x.target command, which links default.target to x.target.

You can specify the default systemd target on the kernel command-line using the option

systemd.unit=x

in the case of going to a single-user mode you have two choices for x, and each has synonyms:

systemd.unit=rescue.target
single
1
each of these kernel command-line options is equivalent. They go to rescue mode (which we know in RH6.5 as single-user mode). Filesystems are mounted read-write
systemd.unit=emergency.target
emergency
These go to emergency mode. The filesystems are not mounted. In this case if you want to change something on the filesystem, you will have to mount the filesystem read-write using mount -o remount,rw / (for the root filesystem)

(Note: even though there are shorthand mechanisms for the general systemd.unit=x option, it is useful to know about it. You can, for example, choose to boot to text mode on a system whose default target is graphical by specifying systemd.unit=multi-user.target at boot time.)

In both cases you can continue the bootup process after making any needed modifications just by typing exit (or, the more general systemctl isolate default.target), or reboot using reboot (systemctl isolate reboot.target). This is because you are using systemd rather than circumventing it.

Booting to single-user mode

Although we discussed this  in the last section, let's review the steps for booting to single-user mode. Single-user mode is needed for performing maintenance operations that may be needed if the system is not booting properly. Briefly, this type of maintenance is performed by:

To modify the boot process to boot to single-user state you must

Problem: I can boot the system, but I've forgotten the root password!

This is the a common problem. It requires starting the system in single-user mode, then running the passwd program after you get a single-user shell. This changes the root password. Unfortunately since systemd will always run the single-user login program sulogin, you must circumvent systemd.

To accomplish this, edit the kernel configuration as above, but instead of changing the systemd target, delete the keywords quiet and rhgb (if they appear), then  add the string init=/bin/sh. This will start bash instead of systemd. This is dangerous and you must be careful.

To avoid having to relabel the filesystem after changing the password, you must load the current SELinux policy. Use the command

/usr/sbin/load_policy -i

Then proceed as follows:

echo "newpassword" | passwd --stdin root

to change the password.

If you change data on the system with this method and do not successfully load the SELinux policy, your system will refuse to read the /etc/shadow file when it boots. This will cause the GUI to fail and you will not be able to log in. To fix this you will have to reboot following the above procedure, create the file /.autorelabel and reboot. Relabeling will take some time when you reboot!

Alternative method to resetting the root password on RH7

The method suggested by Redhat for resetting the root password on a VM on Redhat 7 follows. You can use this as a failsafe method in case the methods above are not successful:


Prev This page was made entirely with free software on linux:  
Kompozer, the Mozilla Project
and Openoffice.org      
Next

Copyright 2015 Greg Boyd - All Rights Reserved.