FreeBSDwiki:Single-user mode
From Ubuntuwiki.net
In single-user mode, there is and can be only one login to the system, which will be the root user. This mode is needed if you want to unmount crucial partitions like /usr or /var, ie for fsck-ing purposes. (You can fsck a mounted partition, but you CAN'T actually repair it while it's mounted - to repair it, you have to unmount it first and THEN fsck it.)
The second CD in the FreeBSD set is a FixIt disk that boots you into single-user mode, and you'll need to do that if something truly terrible happens (you've used /etc/ttys to flag your physical console as insecure and your root password doesn't work after something awful happens). Ordinarily though, if something merely awful happens (like, you mess up your kernel, you delete or mangle your passwd
files, your /etc/fstab doesn't work), you'll be put into single user mode automatically, enabling you to fix the problem, in which case you'll be helpfully prompted to hit Enter for a shell prompt.
Drop to single user mode
FreeBSD docs will frequently tell you to "drop to single user mode". The proper way to do this is with the command, as root:
shutdown now
The shutdown now command doesn't actually stop your machine. Instead, it informs users of the impending stop, disables logins, kills most daemons, logs what has happened, and drops you to single user mode. It's basically equivalent to the command:
init 1
To return to multi-user mode, press ^D
(Ctrl+d), or type:
exit
WARNING: you'd better be physically logged in at a console when you do "drop to single user mode", not shelled in across the network, because when you drop to single-user mode on a box, that box's network capability goes AWAY. This does not accomplish quite the same thing though, as "reboot to single user mode".
Reboot to single user mode
There are several things accomplished by a reboot, that are not done by shutdown
. If the documentation says "reboot to single user mode", it probably means it. Upgrading to CURRENT is a good example - in which case, shutdown now
is considered a hazardous shortcut. The command to reboot is either simply reboot
, or:
shutdown -r
In the bootup process, FreeBSD 5.x and 6.x offer a beastie-start boot menu with a few simple loader options. For example, number 4 is "boot into single user mode" and 6 is "escape to command prompt". FreeBSD 7.x currently doesn't have this menu by default, and 4.x and prior don't have it at all. In those cases, press the space bar to get the command prompt. At the loader prompt type:
boot -s
If you are in single user mode, to attempt to enter multi-user mode you can reboot
, or press ^D
(Ctrl+d), or type:
exit