Apple Intelligence is now available on iPhone, iPad, and Mac!

📢 Newsroom Update

Apple introduces M4 Pro and M4 Max. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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

Reply
29 replies

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?

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/thread/4141712?answerId=19052566022#19052566022

Seems to have a similar problem....

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.

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 ---

----

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?

Feb 23, 2013 12:59 PM in response to Linc Davis

Sure, I can try to boot non-verbosly.


I think I found part of the problem.

further down in the launchctl.c code, /usr/libexec/dirhelper is called.

When I did

sudo mv /usr/libexec/dirhelper /usr/libexec/dirhelper.unused


and rebooted, my machine booted very quickly!!! No 10 minute delay.


Now I don't know what dirhelper does, and why it takes so slow on my machine.... any idea?


Here is my /System/Library/LaunchDaemons/com.apple.bsd.dirhelper.plist:


----

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.apple.bsd.dirhelper</string>

<key>MachServices</key>

<dict>

<key>com.apple.bsd.dirhelper</key>

<true/>

</dict>

<key>ProgramArguments</key>

<array>

<string>/usr/libexec/dirhelper</string>

</array>

<key>RunAtLoad</key>

<true/>

<key>TimeOut</key>

<integer>30</integer>

<key>StartCalendarInterval</key>

<dict>

<key>Hour</key>

<integer>3</integer>

<key>Minute</key>

<integer>35</integer>

</dict>

<key>EnvironmentVariables</key>

<dict>

<key>CLEAN_FILES_OLDER_THAN_DAYS</key>

<string>3</string>

</dict>

</dict>

</plist>


----

Why does my macbook air run fsck every boot

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.