mlachmann

Q: Why does my macbook air run fsck every boot

Sadly, I don't think there really is an answer to my question.

 

Anyway. Some time ago I noticed that my macbook air runs fsck on every boot (which one can see by going to verbose boot mode-cmd-v on boot). This check takes around 10 minutes, which is quite annoying if your computer was rebooted in the middle of giving a talk (that is a different story, though).

 

So, I tried to track down why this happens.

 

1. My root system is HFS journalled.

 

2. First, I booted into rescue mode, and did a check on the disk with DiskUtility. There were indeed some errors to be corrected. They were fixed, and then a second check completed successfully. Still, every boot did fsck.

 

3. I booted into single user mode, and ran fsck -fy. Now nothing was detected, disk is healthy. Still, every boot did fsck.

 

4. I tried to track down, who runs fsck? It started after launchd, so possibly that is the right place. I looked through /System/Library/LaunchDaemons - nothing ran fsck.

 

5. Finally, grep on binaries revealed that launchctl (!!!!) runs fsck.

http://www.opensource.apple.com/source/launchd/launchd-442.26.2/support/launchct l.c revealed that it indeed does.

The relevant code looks like this:

---

if (!is_safeboot()) {

#if 0

/* We have disabled this block for now. We need to revisit this optimization after Leopard. */

if (sfs.f_flags & MNT_JOURNALED) {

goto out;

}

#endif

launchctl_log(LOG_NOTICE, "Running fsck on the boot volume...");

if (fwexec(fsck_tool, &status) != -1) {

---

So, it seems that the "optimization" of not running fsck on every single boot on a journalled filesystem is for now commented out.

 

So, my conclusion is that for now OSX is designed to run fsck on the boot volume every single boot. Whcih on my system takes 10 minutes.

 

My questions are:

 

1. Why?

2. Obviously, currently this can not be disabled. Why?

3. Is it normal that fsck take 10 minutes on an SSD with 250GB?

4. If yes, does boot always take 10 minutes?

MacBook Air, Mac OS X (10.7.5)

Posted on Feb 22, 2013 7:45 AM

Close

Q: Why does my macbook air run fsck every boot

  • All replies
  • Helpful answers

Page 1 Next
  • by Linc Davis,

    Linc Davis Linc Davis Feb 22, 2013 11:12 AM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 22, 2013 11:12 AM in response to mlachmann

    It's indeed normal for fsck to run when you boot in safe mode. The question is whether you are booting in safe mode when you don't intend to. Do you see the words "Safe Boot" in the initial login screen?

  • by mlachmann,

    mlachmann mlachmann Feb 22, 2013 11:54 AM in response to Linc Davis
    Level 1 (4 points)
    Mac OS X
    Feb 22, 2013 11:54 AM in response to Linc Davis

    No, I don't see the words safe mode.

     

    Looking at the source code above, it seems to me that if you DON'T boot in safe mode, fsck is performed,

    but not when you're in safe mode. (Because it says  if (!is_safeboot()) { )

     

    I'll try to boot in safe mode, and see if fsck is skipped....

     

    Does anyone see the same behaviour? Is fsck done on every boot?

  • by Linc Davis,

    Linc Davis Linc Davis Feb 22, 2013 12:06 PM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 22, 2013 12:06 PM in response to mlachmann

    fsck doesn't normally run on every boot. It may run if a problem is detected in the boot volume. You say you found errors on the boot volume when you ran Disk Utility the first time. Was that Repair Disk or Repair Permissions?

  • by mlachmann,

    mlachmann mlachmann Feb 22, 2013 12:41 PM in response to Linc Davis
    Level 1 (4 points)
    Mac OS X
    Feb 22, 2013 12:41 PM in response to Linc Davis

    It was repair disk.

    Repair permissions also reported problems.

    After that I ran repair disk, and verify from diskutil, and fsck in single mode, and they find no problems.

  • by mlachmann,

    mlachmann mlachmann Feb 22, 2013 1:28 PM in response to mlachmann
    Level 1 (4 points)
    Mac OS X
    Feb 22, 2013 1:28 PM in response to mlachmann

    Ok, I tried safe boot. I can easily tell when I'm in safe mode.

    Safe mode also runs fsck, contrary to what I said above. Actually, if you look at the source code of launchctl,

    You see that under safe boot, fsck is also called, but should display a slightly different console message.

    I haven't managed to boot both safe and verbose, and I don't know where to find these boot messages when

    Not in verbose mode, so i haven't seen this different message.

     

    Btw

    https://discussions.apple.com/message/19052566#19052566

    Seems to have a similar problem....

  • by Linc Davis,

    Linc Davis Linc Davis Feb 22, 2013 2:07 PM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 22, 2013 2:07 PM in response to mlachmann

    Check the log from a non-verbose boot and see whether fsck is in fact running.

  • by mlachmann,

    mlachmann mlachmann Feb 22, 2013 2:59 PM in response to Linc Davis
    Level 1 (4 points)
    Mac OS X
    Feb 22, 2013 2:59 PM in response to Linc Davis

    OK, I did a non-verbose, non-safe reboot. It also took a long time.

    As I said above, I'm not sure where the fsck messages go in the log.

    When I look at all messages I see the following:

    2/22/13 11:37:52.934 PM shutdown: reboot by

    2/22/13 11:37:52.934 PM shutdown: SHUTDOWN_TIME: 1361572672 934004

    2/22/13 11:38:20.000 PM bootlog: BOOT_TIME 1361572700 0

    2/22/13 11:48:39.000 PM kernel: PMAP: PCID enabled

    2/22/13 11:48:39.000 PM kernel: Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64

     

    system.log:

    Feb 22 23:37:52 ghostwheel shutdown[444]: reboot by

    Feb 22 23:37:52 ghostwheel shutdown[444]: SHUTDOWN_TIME: 1361572672 934004

    Feb 22 23:38:20 localhost bootlog[0]: BOOT_TIME 1361572700 0

    Feb 22 23:38:21 localhost com.apple.launchd[1]: *** launchd[1] has started up. ***

    Feb 22 23:48:39 localhost com.apple.launchd[1] (com.apple.powerd): Unknown value for key POSIXSpawnType: Interactive

     

    fsck_hfs.log:

    /dev/rdisk0s2: fsck_hfs run at Fri Feb 22 23:48:40 2013

    /dev/rdisk0s2: ** /dev/rdisk0s2 (NO WRITE)

    /dev/rdisk0s2: ** Root file system

    /dev/rdisk0s2:    Executing fsck_hfs (version diskdev_cmds-540.1~25).

     

     

    /dev/rdisk0s3: fsck_hfs run at Fri Feb 22 23:48:40 2013

    /dev/rdisk0s3: ** /dev/rdisk0s3 (NO WRITE)

    /dev/rdisk0s3:    Executing fsck_hfs (version diskdev_cmds-540.1~25).

    QUICKCHECK ONLY; FILESYSTEM CLEAN

     

    As you can see, there is a hole from 23:38 to 23:48, during which I susect fsck ran. On a verbose boot I see before the hole the message "Running fsck on the boot volume..." on screen, but I can't find it in the non-verbose log.

  • by Linc Davis,

    Linc Davis Linc Davis Feb 22, 2013 3:50 PM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 22, 2013 3:50 PM in response to mlachmann

    Try resetting the NVRAM.

     

    About NVRAM and PRAM

  • by mlachmann,

    mlachmann mlachmann Feb 22, 2013 11:47 PM in response to Linc Davis
    Level 1 (4 points)
    Mac OS X
    Feb 22, 2013 11:47 PM in response to Linc Davis

    OK, I reset nvram and pram with opt-cmd-pr.

    And, fsck is still run on boot.

     

    Could you maybe CHECK that on verbose boot, fsck is not run?

    It is one of the first messages after launchd starts.

     

    Maybe the problem isn't that it is run, but that it takes 10 min?

  • by Linc Davis,

    Linc Davis Linc Davis Feb 23, 2013 8:28 AM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 23, 2013 8:28 AM in response to mlachmann

    Except in single-user mode, fsck_hfs doesn't run automatically during the boot process unless the journal is dirty on mount. If the journal is dirty, something is wrong with your drive or your OS. All you have to do is search for "fsck" in the system log. Don't boot verbosely.

  • by mlachmann,

    mlachmann mlachmann Feb 23, 2013 8:47 AM in response to Linc Davis
    Level 1 (4 points)
    Mac OS X
    Feb 23, 2013 8:47 AM in response to Linc Davis

    I just checked a friend's pro. It also executes fsck on every boot, but

    his boots just take a jiffy, and the log says:

    QUICKCHECK ONLY; FILESYSTEM CLEAN

     

    My log says this for disk0s3 but not for disk0s2, which takes 10 minutes, I think.

    So how come fsck doesn't do a quickcheck, and instead does a full check?

     

    Thanks!

  • by mlachmann,

    mlachmann mlachmann Feb 23, 2013 11:17 AM in response to mlachmann
    Level 1 (4 points)
    Mac OS X
    Feb 23, 2013 11:17 AM in response to mlachmann

    Now I'm not sure that the problem is fsck.

    I booted into single mode, and ran fsck_hfs or fsck with flag -q on each partition. In each case, it finishes

    very quickly. Maybe something else is wating 10 minutes.... how could I check what it is?

     

    Here is my system.log arund the boot, again:

    --

    Feb 23 17:57:31 localhost com.apple.launchd[1]: *** launchd[1] has started up. ***

    Feb 23 17:57:31 localhost com.apple.launchd[1]: *** Verbose boot, will log to /dev/console. ***

    Feb 23 18:07:49 localhost com.apple.launchd[1] (com.apple.powerd): Unknown value for key POSIXSpawnType: Interactive

    Feb 23 18:07:49 localhost com.apple.launchd[1] (com.apple.sandboxd): Unknown value for key POSIXSpawnType: Interactive

    Feb 23 18:07:49 localhost fseventsd[18]: event logs in /.fseventsd out of sync with volume.  destroying old logs. (21 618 1040)

    Feb 23 18:07:49 localhost fseventsd[18]: log dir: /.fseventsd getting new uuid: 8014F450-D0ED-4E2E-A0AE-1F3B866EC793

    Feb 23 18:07:50 localhost UserEventAgent[9]: starting CaptiveNetworkSupport as SystemEventAgent built May 25 2011 12:27:35

    Feb 23 18:07:50 localhost UserEventAgent[9]: CaptiveNetworkSupport:CreateInterfaceWatchList:2788 WiFi Devices Found.

    Feb 23 18:07:50 localhost UserEventAgent[9]: CaptiveNetworkSupport:CaptivePublishState:1211 en0 - PreProbe

    Feb 23 18:07:50 localhost UserEventAgent[9]: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order

    Feb 23 18:07:50: --- last message repeated 1 time ---

    Feb 23 18:07:50 localhost UserEventAgent[9]: CaptiveNetworkSupport:CaptivePublishState:1211 en0 - PreProbe

    Feb 23 18:07:50 localhost UserEventAgent[9]: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order

    Feb 23 18:07:50: --- last message repeated 1 time ---

    Feb 23 18:07:50 localhost mDNSResponder[10]: mDNSResponder mDNSResponder-320.16 (Jul 19 2012 21:07:07) starting OSXVers 11

    Feb 23 18:07:50 localhost airportd[23]: _processDLILEvent: en0 attached (down)

    Feb 23 18:07:51 localhost UserEventAgent[9]: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order

    Feb 23 18:07:51: --- last message repeated 1 time ---

    ----

  • by mlachmann,

    mlachmann mlachmann Feb 23, 2013 12:41 PM in response to mlachmann
    Level 1 (4 points)
    Mac OS X
    Feb 23, 2013 12:41 PM in response to mlachmann

    I figured out that it isn't fsck:

     

    In the code for launchctl, there is a routine called fix_bogus_file_metadata(), which will

    complain if /Library/StartupItems is not present, and recreate it. This is called AFTER fsck finished.

    I renamed the directory, and on reboot saw that the Warning message:

    "Crucial filesystem check: Path not present: /Library/StartupItems"

    comes up after the fsck message, but before the 10 minutes wait time.

     

    So, what else could be holding up the boot?

  • by Linc Davis,

    Linc Davis Linc Davis Feb 23, 2013 12:50 PM in response to mlachmann
    Level 10 (208,059 points)
    Applications
    Feb 23, 2013 12:50 PM in response to mlachmann

    The gap in the log is due to the verbose boot. During the boot phase, messages are logged to the console rather than to syslogd. To see a complete log, you have to boot non-verbosely, as I wrote earlier.

Page 1 Next