Intro to Single-user mode:
To get to single-user mode, hold down the command (i.e. cloverleaf or Apple) and “s” keys as the system begins to boot. This will drop you into a command line interface before the system has fully started up, giving you the chance to check/repair things before much of the normal OS X environment starts up.
Single-user mode starts you with an extremely minimal environment – not only is the normal graphical interface not running, neither are most of the normal system daemons (init and mach-init are the only ones), and the boot disk isn’t even fully mounted! Usually, you want to bring at least a little more of OS X up in order to get anything useful done. Exactly how much depends on what you want to do, but usually you want to either just mount the boot volume for write access, or do that and then start the various system daemons and components (e.g. networking) that make up most of the non-graphical parts of Mac OS X.
Mounting the boot volume for write access:
fsck -y
- Check the boot volume’s file system, and repair if necessary (the “-y” means “Yes, go ahead and fix any problems you find”). Always do this first. Note that this may not be able to fix all problems in a single pass, so if it finds and fixes anything (it’ll print “ FILE SYSTEM WAS MODIFIED “), run it again, and keep running it until it comes back with something like “The volume Macintosh HD appears to be ok.”
Note: If the volume has journalling enabled, you should get a message like
fsck_hfs: Volume is journaled. No checking performed.
fsck_hfs: Use the -f option to force checking.
In this case it should be reasonably safe to go ahead and mount the volume, since the journal should have taken care of any necessary repairs. But I’m paranoid, so I tend to recommend using fsck -yf to force a full check.
See Apple’s TIL article #106214 for more info.
mount -uw /
- Remount the boot volume, enabling write access. You need to do this before you can change anything on disk, but always run fsck first.
Note: if this command works, it won’t give you any output (other than another shell prompt). If it prints something like:
root_device on / (local, read-only)
devfs on /dev (local)
then you probably mistyped the command.
Starting system daemons and components:
Depending on what you need to accomplish in single-user mode, you may (or may not) need to start up more of the operating system’s normal components (access to disks other than the boot volume, networking, etc). This part of the process works a bit differently depending on what version of Mac OS X you’re using. Under 10.0 through 10.2, the SystemStarter command is all it takes. Under 10.3, you need to register the Mach services, then launch netinfod manually, then finally invoke SystemStarter to finish the job. Under 10.4, it gets easy again: you can use /etc/rc to do the work for you.
After running any of these commands, do not attempt to continue the boot with the exit command. If you aren’t sure what version you have, use sw_vers to find out.
0 comments:
Post a Comment