Mac OS X Server 1.x: Why, When, and How to Run fsck for File System Maintenance

This article details common reasons an administrator might need to run the fsck ('file system check') utility, and describes the means of so doing, from the single-user shell, when booted from the default system drive, or from the system software installer CD.
Note: This article pertains to Mac OS X Server versions 1.x, which were released prior to May 2001.

The fsck utility is used to perform routine maintenance and recovery on a Mac OS X system hard disk that has either become unbootable or will not start to multi-user mode due to events or occurrences such as improper shutdown, forced restart, power outage, an accidentally disconnected power cord, and so forth.

There are several possible situations that may cause a Mac OS X system drive to fail to boot properly into the full Mach/BSD environment. Common causes of this issue include improper shutdown, power outage, pilot or visitor error such as kicking a power cord, UPS failure, improper use of front-panel buttons, or a full system disk. Yes, Mac OS X does permit the command-control-Power key restart, but don't do it!

Improper shutdown or a forced power cycle are always valid reasons to run the fsck utility to repair the system drive.

There are two environments from which fsck may be run. Normally, after an improper shutdown, workspace manager stops responding, or other untoward event, the system will do a partial boot, and pause in a command line environment following basic hardware initialization. Under these circumstances, there will usually be an error message, such as 'file system dirty, run fsck', followed by a new line with a # (pound-sign) prompt. In this event, fsck can be run directly, with no other maneuvering required.

In severe situations, the system information may be sufficiently unusable that the system will not get as far as the # prompt. Under these circumstances, it is necessary to boot from some other Unix-style system and manually specify the system drive as the target for fsck.

Usually, you'll know you need to do this, because when you started your system, it would only go as far as the single-user shell (the # <pound sign> prompt, as detailed above).

If the system realizes that the file system is dirty, there will be a message saying so, and what to do about it.

If the system doesn't boot up as far as the # prompt, then it will be necessary to start from some other volume, such as the Mac OS X Server Installer CD, in single-user mode. If this is your plight, skip down to the section "How To Run fsck From The Mac OS X Installer CD" below.

How To Run fsck From The Startup Disk


How To Run fsck From The Mac OS X Installer CD

Maintenance can be done on a Mac OS X formatted hard drive that won't start up by performing the following steps:


What To Do If fsck Doesn't Execute As Expected

There are two relatively common reasons why fsck might not run, even if you follow the above directions.


Other Possible Reasons fsck Might Not Run

Mach/BSD Doesn't Know Path To Device Driver

If for some reason Mach/BSD isn't sure on which drive the startup software resides, it may help to include the entire path to the command and to the target device driver:
/sbin/fsck -y /dev/hda0a
This is correct for an internal ATAPI drive 0, with the Mac OS X Server on the first partition.
/sbin/fsck -y /dev/sd1a
This is the syntax to designate a SCSI drive with ID=1.
At the # prompt (single-user command line mode), utilities and commands such as rm, mv, vi, cd, find, disk and so forth will run just fine, and won't need the full path; the startup drive may be assumed for some, such as fsck.

Master Superblocks Missing Or Unusable

If problems are encountered reading the master superblocks, the first alternate superblocks may be read instead, by adding the -b16 argument:
fsck -y -b16 /dev/hd0a
This can be useful if the system lost power when changed directory information was cached but not yet written back to disk before the system went down.

Run It Again, Sam

Note: If anything is altered, repaired or fixed during a file system check by the fsck utility, the message:
***** FILE SYSTEM WAS MODIFIED *****
will appear at the end of execution, just prior to a return to the root prompt (#). If this result occurs, it indicates that changes were made to the filesystem. It is important to run fsck again, until this message no longer appears. If the -b16 argument is used, this message will always appear, so by definition, if the -b16 argument is used, fsck must always be run again without the -b16 as a verification that all is well.

To Continue...

Once fsck runs without error, you may continue your use of the computer with one of the following commands:
exit (the single-user shell)
reboot (restarts and proceeds through a normal boot)
shutdown (powers the computer off)


Disk Too Full For Scratch Area

Note: If the system disk is full (showing no or very few free blocks) fsck may fail to run properly. If the disk really is full (full in this sense means less than 5% free disk space), you must mount the root file system by following the instructions printed just before the single-user prompt (#) is displayed:
/sbin/mount -uw /
and then use the 'rm' command to remove a few files to make a little space on the hard disk. Any core-dump files in /cores will be of substantial size, and if not needed for diagnostics are quite expendable. Careful consideration should be given as to which files are to be discarded, as there is no 'undelete' available in Unix-style operating systems.
rm /cores/[filename]
rm /Local/Users/[username]/Library/OmniWeb/Bookmarks.html
For more information on removal of files from command line, see the man pages on 'rm', rmdir', 'disk', and 'rmdir'.

Other Information About Most Commands Abounds In The man Pages

Man pages are available in single user mode only if the '/' file system is mounted, because the pages must be written to disk temporarily.
man rm
man rmdir
man fsck
man disk
Remember, viewing man pages in single-user mode requires that the root file system be mounted (see 'Disk Too Full...' above).

Published Date: Feb 18, 2012