Languages

Resolve startup issues and perform disk maintenance with Disk Utility and fsck

Symptoms

If your computer won't start up normally, you may need to use a disk repair utility to fix the issue. Mac OS X includes two utilities for this—Disk Utility and fsck (a command-line utility). You can also use these even when your computer starts just fine but you want to check the disk for possible file system issues. For Mac OS X 10.4.3 or later, check out "About live verification in Mac OS X 10.4.3 or later," below.

Important: If you're using Mac OS X 10.4 or later, you should use Disk Utility instead of fsck, whenever possible.

In some situations, file system errors may prevent your computer from starting up. This can occur after an improper shutdown, forced restart, or power interruption. If your computer shows any of the following symptoms on startup, use a disk repair utility:

  • Your computer partially starts but then displays a command line in a text-only environment. You may see the message, "file system dirty, run fsck." Below it, you'll see what's called a command-line prompt, indicated by a number sign (#), that allows you to type a command. If you see this, you'll need to run fsck from the command line (see "Use fsck if necessary," below).
  • Your computer starts but either it won't reach the login screen, or it may reach the login screen but not load the Desktop after you log in. However, you can start up in single-user mode.

If your computer exhibits either of the above issues, here are some things to try to get your computer back to starting up properly again. If you can't start from the Recovery System or Internet Recovery in OS X Lion and Mountain Lion, or you can't find the system discs that came with your computer, see "Use fsck," below.

Resolution

Try a Safe Boot

If you're using Mac OS X 10.2 or later, you can start up your computer in Safe Mode, which includes an automatic disk check and repair. If you're using Mac OS X 10.1.5 or earlier, skip to the next section. A Safe Boot, which starts up your computer into Safe Mode, may allow you to start up your computer successfully using a reduced version of the system software. To do this, follow these steps:

  1. Start up in Safe Mode.
  2. After the system has fully started up, restart your computer again normally.

If the computer successfully restarts, you do not need to do any more troubleshooting. If the issue persists, try Disk Utility.

Try Disk Utility

  1. Start from the Recovery System or Internet Recovery (OS X Lion or Mountain Lion).
    If your computer shipped with a Mac OS X Install disc, insert the installation disc, and restart the computer while holding the C key.
  2. If using a Recovery partition or Internet Recovery (OS X Lion and later): When your computer finishes starting up, choose Disk Utility from the Utilities window.
    If using an installation disc: Choose Disk Utility from the Installer menu.
    Important: If you started from an installation disc, do not click Continue in the first screen of the Installer. If you do, you must start from the disc again to access Disk Utility.
  3. Click the First Aid tab.
  4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
  5. Select your OS X volume.
  6. Click Repair. Disk Utility checks and repairs the disk.

Tip: With Mac OS X v10.6 and earlier, always start up your computer from an Install or Restore disc when using Disk Utility to verify or repair your startup volume. Otherwise, you might see some disk error messages.

Use fsck if necessary

fsck is a command-line utility that may be able to verify and repair a disk. If you can successfully start up in Safe Mode or use Disk Utility while started up from a disc, you don't need to use fsck. Here are some situations in which fsck may be necessary.

  • Your Mac OS X disc isn't available.
  • Your optical drive isn't available.
  • You can't start with a Safe Boot by holding the Shift key during start up.
Tip: If you use a Mac OS X Extended (Journaled) formatted volume, such as with Mac OS X 10.3 or later, you probably won't need to use fsck. If you do use it for any reason, please be aware that benign error messages can appear.

If you're not sure how your volume is formatted and you can't start up from your Mac OS X volume to find out, type the following command in a command-line interface and then press Return: diskutil info /

If you see "File System: Journaled HFS+" returned, you have a Journaled volume.

To use fsck, you must run it from the command line. Unlike using your mouse pointer to open an application to do something, you'll need to type a text command at the prompt (#) to tell fsck what to do. The Terminal application (/Applications/Utilities) and single-user mode are two examples of command-line interfaces in which you can type such commands. To use fsck:

  1. Start up your computer in single-user mode to reach the command line.
    Note: If necessary, perform a forced restart as described in the Emergency Troubleshooting Handbook that came with your computer. On desktop computers, you can do this by pressing the reset/interrupt button (if there is one) or holding down the power button for several seconds. On portable computers, simultaneously press the Command-Control-power keys. If your portable computer doesn't restart with this method, you may need to reset the Power Manager.
  2. At the command-line prompt type:

    /sbin/fsck -fy

  3. Press Return. fsck will go through five "phases" and then return information about your disk's use and fragmentation. Once it finishes, it'll display this message if no issue is found:
    ** The volume (name_of_volume) appears to be OK
    If fsck found issues and has altered, repaired, or fixed anything, it will display this message:
    ***** FILE SYSTEM WAS MODIFIED *****
    Important: If this message appears, repeat the fsck command you typed in step 2 until fsck tells you that your volume appears to be OK (first-pass repairs may uncover additional issues, so this is a normal thing to do).
     
  4. When fsck reports that your volume is OK, type reboot at the prompt and then press Return.

Your computer should start up normally and allow you to log in.

 

Additional Information

About live verification in Mac OS X 10.4.3 or later

In Mac OS X 10.4.3 or later, you can verify your Mac OS X volume while started from it. This is known as live verification, and can be used in three different ways.

Option 1: Verify your disk using Disk Utility while started from the startup disk. To find out how to do this, see this article. Please note that live verification does not involve any disk repair, so if verification finds something that should be repaired, start up from your Mac OS X Install disc and use Disk Utility as described above in "Try Disk Utility."

Option 2 (advanced): Use the command line and the command-line utility, diskutil.

  1. Start up your computer and log in as an administrator.
  2. Open Terminal (/Applications/Utilities).
  3. At the prompt, type the following command and then press Return:

    diskutil verify /

Note: Don't use this method to check non-startup volumes.

You should see messages such as the following during the disk check:

Could not unmount disk for verification, attempting live verify
Started verify/repair on volume disk0s3 Macintosh HD
Checking HFS Plus volume.
Checking Extents Overflow file.
Checking Catalog file.
Checking multi-linked files.
Checking Catalog hierarchy.
Checking Extended Attributes file.
Checking volume bitmap.
Checking volume information.
The volume Macintosh HD appears to be OK.
Mounting Disk
Verify/repair finished on volume disk0s3 Macintosh HD

Option 3 (advanced): Use the command line and the fsck_hfs -l command.

  1. Start up your computer and log in as an administrator.
  2. Open Terminal (/Applications/Utilities).
  3. At the prompt, type the following command and then press Return to determine your filesytem ID:

    df -hl
  4. Look for some lines of text that look like this:

    Filesystem Size Used Avail Capacity Mounted on
    /dev/disk0s3 37G 20G 17G 55% /
    /dev/disk0s5 37G 37G 641M 98% /Volumes/Storage

     
  5. Make a note of the first "disk" name that appears after /dev/, such as "disk0s3." This is your filesystem ID for your startup volume.
  6. At the prompt, type the following command and then press Return:

    df -hl
  7. Then type the following command, where "disk0s3" is your filesystem ID you noted in step 4, then press Return:

    sudo fsck_hfs -l /dev/disk0s3
  8. When prompted, enter your admin password, then press Return to begin the verification.
  9. You should see messages like these during the disk check:

    ** /dev/rdisk0s3 (NO WRITE)
    ** Root file system
    ** Checking HFS Plus volume.
    ** Checking Extents Overflow file.
    ** Checking Catalog file.
    ** Checking multi-linked files.
    ** Checking Catalog hierarchy.
    ** Checking Extended Attributes file.
    ** Checking volume bitmap.
    ** Checking volume information.
    ** The volume Macintosh HD appears to be OK.

Advanced information

If you're interested in UNIX-style command-line syntax, here's a look at how a couple of flags used above can influence fsck:

  • The -y flag: Tells fsck that you want to answer "yes" to all questions about fixing, repairing, or salvaging information. This is the optimal approach, as answering "no" to any question causes fsck to stop. You cannot determine that all necessary repairs have been made until fsck completes and gives its final report.
  • The -f flag: Forces fsck to check "clean" filesystems when preening.
Last Modified: Sep 19, 2012
Helpful?
Yes
No
  • Last Modified: Sep 19, 2012
  • Article: TS1417
  • Views:

    140760
  • Rating:
    • 20.0

    (1 Responses)

Additional Product Support Information

Start a Discussion
in Apple Support Communities
See all questions on this article See all questions I have asked