Search

Top Posts

Comments

  • Dan: You’d definitely need a microphone, mic stand and usb audio interface for a start!
  • Sepp: Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal...
  • jeffcard: Nice guide, thanks for sharing, here is a step by step guide regarding how to convert DVD, video and audio,...
  • James: Well, it hasn’t crashed on me yet, and I’ve been using it for at least 2 months now…
  • Dasher: Any experience creating a RAM disk, specifically for helping iTunes run faster? I am on a 2006 Imac 21″...

Categories

Recent Posts


What happens in the Mac OS X boot process?

Long gone are the days of OS 9, watching our Macs boot up with a series of extensions and control panels that we could always identify. Today with the Unix underpinnings of OS X, many users are entirely unaware of what is going on behind the scenes. So what exactly happens during the Mac OS X boot process? A segment at KernelThread carefully lists the sequence of events, from start to finish. It is fairly thorough and worth a read. It is repeated below for the inquisitive Mac OS X users out there.


Note: As a reader pointed out, PPC uses OF, i386 uses EFI

You turn on your Mac, and this is what happens:

  • Power is turned on.
  • OF or EFI code is executed.
  • Hardware information is collected and hardware is initialized.
  • Something (usually the OS, but also things like the Apple Hardware Test, etc.) is selected to boot. The user may be prompted to select what to boot.
  • Control passes to /System/Library/CoreServices/BootX, the boot loader. BootX loads the kernel and also draws the OS badges, if any.
  • BootX tries to load a previously cached list of device drivers (created/updated by /usr/sbin/kextcache). Such a cache is of the type mkext and contains the info dictionaries and binary files for multiple kernel extensions. Note that if the mkext cache is corrupt or missing, BootX would look in /System/Library/Extensions for extensions that are needed in the current scenario (as determined by the value of the OSBundleRequired property in the Info.plist file of the extension’s bundle.
  • The init routine of the kernel is executed. The root device of the booting system is determined. At this point, Firmware is not accessible any more.
  • Various Mach/BSD data structures are initialized by the kernel.
  • The I/O Kit is initialized.
  • The kernel starts /sbin/mach_init, the Mach service naming (bootstrap) daemon. mach_init maintains mappings between service names and the Mach ports that provide access to those services.

From here on, the startup becomes user-level:

  • mach_init starts /sbin/init, the traditional BSD init process. init determines the runlevel, and runs /etc/rc.boot, which sets up the machine enough to run single-user.

During its execution, rc.boot and the other rc scripts source /etc/rc.common, a shell script containing utility functions, such as CheckForNetwork() (checks if the network is up), GetPID(), purgedir() (deletes directory contents only, not the structure), etc.

  • rc.boot figures out the type of boot (Multi-User, Safe, CD-ROM, Network etc.). In case of a network boot (the sysctl variable kern.netboot will be set to 1 in which case), it runs /etc/rc.netboot with a start argument.

/etc/rc.netboot handles various aspects of network booting. For example, it performs network and (if any) local mounts. It also calls /usr/bin/nbst to associate a shadow file with the disk image being used as the root device. The idea is to redirect writes to the shadow file, which hopefully is on local storage.

  • rc.boot figures out if a file system consistency check is required. Single-user and CD-ROM boots do not run fsck. SafeBoot always runs fsck. rc.boot handles the return status of fsck as well.
  • If rc.boot exits successfully, /etc/rc, the multi-user startup script is then run. If booting from a CD-ROM, the script switches over to /etc/rc.cdrom (installation).
  • /etc/rc mounts local file systems (HFS+, HFS, UFS, /dev/fd, /.vol), ensures that the directory /private/var/tmp exists, and runs /etc/rc.installer_cleanup, if one exists (left by an installer before reboot).
  • /etc/rc.cleanup is run. It “cleans” a number of Unix and Mac specific directories/files.
  • BootCache is started.
  • Various sysctl variables are set (such as for maximum number of vnodes, System V IPC, etc.). If /etc/sysctl.conf exists (plus /etc/sysctl-macosxserver.conf on Mac OS X Server), it is read and sysctl variables contained therein are set.
  • syslogd is started.
  • The Mach symbol file is created.
  • /etc/rc starts kextd, the daemon process that loads kernel extension on demand from kernel or client processes.
  • /usr/libexec/register_mach_bootstrap_servers is run to load various Mach bootstrap based services contained in /etc/mach_init.d
  • portmap and netinfo are started.
  • If /System/Library/Extensions.mkext is older than /System/Library/Extensions, /etc/rc deletes the existing mkext and creates a new one. It also creates one if one doesn’t exist.
  • /etc/rc starts /usr/sbin/update, the daemon that flushes internal file system caches to disk frequently.
  • /etc/rc starts the virtual memory system. /private/var/vm is set up as the swap directory. /sbin/dynamic_pager is started with the appropriate arguments (swap filename path template, size of swap files created, high and low water alert triggers specifying when to create additional swap files or delete existing ones).
  • /etc/rc starts /usr/libexec/fix_prebinding to fix incorrectly prebound binaries.
  • /etc/rc executes /etc/rc.cleanup to clean up and reset files and devices.
  • /etc/rc finally launches /sbin/SystemStarter to handle startup items from locations such as /System/Library/StartupItems and /Library/StartupItems. A StartupItem is a program, usually a shell script, whose name matches the folder name. The folder contains a property list file containing key-value pairs such as Description, Provides, Requires, OrderPreference, start/stop messages etc. You can run SystemStarter -n -D as root to have the program print debugging and dependency information (without actually running anything).
  • The CoreGraphics startup item starts the Apple Type Services daemon (ATSServer) as well as the Window Server (WindowServer).

Source: KernelThread

Posted by: Editor

Share

Save big on Mac Deals from Amazon.com

Comments:

Comments: 52

Comment from anon
Time: January 22, 2007, 9:01 pm

are intel macs still using OF? I thought we were on EFI

Comment from janson
Time: January 23, 2007, 4:59 pm

Anon, yes the intel uses EFI.

Comment from Hugh
Time: January 24, 2007, 9:37 am

launchd?

Comment from sasi
Time: January 24, 2007, 9:46 am

So , is it faster or better than upstart way of booting. as in Ubuntu?

Comment from Motorcycle Guy
Time: January 24, 2007, 9:55 am

does any of this matter? its not like you can change anything really? I mean I guess the only difference between this and the way windows starts up is more of the components have a recognized name.

Comment from Michael Coyle
Time: January 24, 2007, 10:13 am

The reason it’s good to know this is so that when something goes wrong very early in the boot process, you can get an idea of what’s wrong.

For example, if the Apple logo doesn’ t show up, you never made it to BootX and the drive maybe bad.

Comment from Edwin
Time: January 24, 2007, 10:15 am

OSX is very fast in loading up, unlike Windows Xp which takes forever. I hope Vista does a better job in this.

Comment from winston smith
Time: January 24, 2007, 10:31 am

Retard.

Comment from jack
Time: January 24, 2007, 12:27 pm

Personal mac powerbook pro OS/X boots to logon panel in 18 seconds, less than 5 seconds to usable computer. Office Win 2k boots to logon panel in about 5 minutes, at least 3 more minutes to the desktop. you choose!!!

Comment from durin42
Time: January 24, 2007, 12:31 pm

IIRC this is the boot sequence as of 10.3 machines – 10.4 doesn’t use init, but rather uses launchd in its place:
imladris:~ durin$ ps axwwu | grep init
durin 775 0.0 0.0 27364 436 p1 R+ 1:31PM 0:00.00 grep init
imladris:~ durin$ ps axwwu | grep launchd
root 35 0.0 0.2 28576 1756 ?? Ss 10:34PM 0:00.89 /usr/sbin/mDNSResponder -launchdaemon
durin 777 0.0 0.0 27364 440 p1 S+ 1:31PM 0:00.00 grep launchd
root 1 0.0 0.1 28352 560 ?? S

Comment from Digg sucks
Time: January 24, 2007, 12:34 pm

Yes, Digg SPAM! Go to a website, copy its contents, paste it into your BLOG, then SPAM DIGG and watch the money roll in as Diggtards click on Yahoo ads. Oh bummer, Diggtards don’t click on ads, they just show up en mass and then leave again.

Next time, just link to the author, rather than ripping off his writing. What an asshole

Comment from Bush
Time: January 24, 2007, 1:06 pm

Say, Bill. Would you rub some of this powder on my lips?

Comment from Alpharetta
Time: January 24, 2007, 4:57 pm

Interesting to note that launchd is the more more modern approach, but from what I read init actually has advantages, mainly with the kernel.

I really don’t know anything

Pingback from SearchRoads » final fantasy unlimited-vivid mp3 What happens in the Mac OS X boot process?
Time: January 24, 2007, 5:00 pm

[...] final fantasy unlimited-vivid mp3 Long gone are the days of OS 9, watching our Macs boot up with a series of extensions and control panels that we could always identify. Today with the Unix underpinnings of OS X, many users are entirely unaware of what is going on behind the scenes. So what exactly happens during the Mac OS X boot process? final fantasy hentai englishread more | digg story [...]

Pingback from What happens in the Mac OS X boot process? « Universe_JDJ’s News Blog
Time: January 24, 2007, 5:58 pm

[...] read more | digg story [...]

Comment from Spiderman Was Here
Time: January 24, 2007, 9:41 pm

Folks , You have too much free time to worry about this.

Pingback from de tomKronieken » Blog Archive » links for 2007-01-24
Time: January 25, 2007, 3:32 pm

[...] OS X Daily ยป What happens in the Mac OS X boot process? – Mac OS X Apps, Tips, Tricks, News, Updates, Everything Mac OS X (tags: macosx) [...]

Comment from Stripes
Time: January 26, 2007, 12:50 am

“Interesting to note that launchd is the more more modern approach, but from what I read init actually has advantages, mainly with the kernel.”

I can’t think of any kernel level advantage of init vs. launchd. init runs a lot more processes, the rc scripts typically start programs serially. launchd allocates more network (and mach ports) then init, and then starts a bunch of stuff more or less all at once (and in many cases starts fewer things then the rc scripts).

On some unix and unix like systems adopting a launchd like startup might cause a lot more disk thrashing and could result in a slower boot. On OS X there is some boot-time disk replay logic that pretty much keeps the disk from thrashing.

launchd does use more kernel facilities then init did, but that is more because it pretty much does the job of /etc/rc, inetd and mach_init. None of those facilities are unusual (say select, or kqueue), just not used by init.

I would far rather have launchd on OS X. On a system without a boot cache, it might not be as useful for fast booting (but it does have other advantages).

Comment from Nick
Time: January 26, 2007, 4:53 am

If anyone has any ideas and cares to share I would appreciate (I know this is not a tech forum….just covering all my bases). I look after 2 computer labs with 25 eMacs each (G4 1.42Ghz,768MB,80GB,Tiger10.4.8) at a school. At any point in time to a couple of random machines, they will refuse to boot…..they get to the grey apple logo and either locks up before the spinner appears or the spinner just spins indefinatly. It usually takes about 3 or 4 forced power offs or a netboot to get them to finally boot properly. Like I said, it happens at random times to any one (or couple) of the 50 computers and it doesn’t follow any pattern (eg. if a computer refuses to boot and you finally get it to boot, it might work perfectly for months before anything else goes wrong and there are others that do it on a weekly basis). Our head tech has not got a clue and has tried everything he knows. Does anybody know of random booting issues that might occur in a network environment? Thanks.

Pingback from ChoJin’s Quarter » Links of the Week 2
Time: January 29, 2007, 1:34 am

[...] Mac OS X Boot Process [...]

Pingback from In Through The Out Door » Mac OS X boot process
Time: February 4, 2007, 11:41 am

[...] What happens in the Mac OS X boot process: [...]

Pingback from Mac OS X Boot Process | Dan’s Stuff
Time: February 7, 2007, 7:43 pm

[...] read more | digg story [...]

Comment from screwer
Time: May 21, 2007, 3:47 am

is there a way to force osx to boot instead of os 9 cus i ive just selected to boot os 9 on my powerbook g4 and when tried to boot jus get an hapy face icon blinking

Comment from lipitor
Time: May 29, 2007, 9:05 am

Mac OS X is the best in the world! It needs not so much resources and not so much time to install. I think over the years will improve.

Comment from ebere
Time: July 10, 2007, 5:43 am

what happend durring the process of booting?

Comment from Doug Weight
Time: August 14, 2007, 11:15 pm

Great article. I have bookmarked this for future reference. Mac OSX is powerful.

Comment from Michael
Time: September 10, 2007, 3:19 am

Thanks for the info! I really wanted to know how the process occurs. All this happens in about 20 seconds. PC takes about 2 minutes to completely load!

Comment from weight loss tips
Time: September 26, 2007, 1:59 pm

i don’t know, I personally prefer Vista (sarcasm)

Comment from mzfniamm
Time: October 17, 2007, 2:05 pm

Mac OS X is the best in the world! It needs not so much resources and not so much time to install. I think over the years will improve.

Pingback from MacOS » Blog Archive » What happens in the Mac OS X boot process?
Time: October 23, 2007, 2:55 pm

[...] read more | digg story [...]

Comment from Jack
Time: October 29, 2007, 5:22 am

Now that Mac OS X is based on the i386 platform, I’m thinking of switching to it from XP. Any advice?

Pingback from Apple is Not Fruit » What happens in the Mac OS X boot process?
Time: November 9, 2007, 4:27 am

[...] read more | digg story [...]

Comment from JT Harrison
Time: November 13, 2007, 2:02 pm

Good to know! But yet it doesn’t help much, though. It’s very unlikely any of us to be able to do anything if something goes wrong.

Not that it’s not good to know the problem by name, but you won’t be able to do and change anything, right?

Comment from chunky_woman
Time: December 8, 2007, 3:45 am

1.42Ghz,768MB,80GB- -nice comp

how do u start in the mac os x 10.5?

Comment from john
Time: December 22, 2007, 11:27 am

Wow.. Mac is better.. they just need better advertising.

Comment from Craig
Time: December 23, 2007, 11:43 pm

MAC OSX is by far the best,…

Comment from big bob
Time: January 1, 2008, 10:01 pm

simple question…you know how in windows you can search for a file on the entire hard drive by typing dir *.doc /s does anyone how to do this from terminal?

Comment from alex
Time: January 17, 2008, 6:47 pm

To search for a file through the entire actual partition, you can use:

$ find / -name “file.ext”

where file.ext is the name and extension of the file to be searched.

It’s the same as in other *NIX system, I think.
Alex

Comment from BillyBoy
Time: January 28, 2008, 10:21 am

I just love Apple designs..

Pingback from The Cave » Blog Archive » What happens in the Mac OS X boot process?
Time: April 13, 2008, 6:20 pm

[...] Nice. [...]

Comment from internet
Time: July 19, 2008, 3:38 pm

This all is no longer true. In the Leopard everything changed and the mentioned scripts no longer exists. Over time unix-like features stolen from BSD-Unix became more and more crippled. Fare well OSX …

Comment from chris
Time: July 22, 2008, 9:49 am

great designs

Comment from zyrtec
Time: November 17, 2008, 1:49 pm

Thanks for the run down of Mac OS. Always been a PC owner myself just because i’m more familiar with it. Thinking for buying Mac.

Comment from Canadianfff
Time: November 20, 2008, 12:55 pm

Nice article, had no idea what happens when Mac OS loads.

Comment from Odor Eliminators
Time: January 28, 2009, 4:32 pm

Do you know if Mac is going to develop another OS X boot process? I’d be interested in finding out. Thanks.

Comment from dongakolonga
Time: July 5, 2009, 3:30 am

specialty is erectile dysfunction treatment

Comment from homs
Time: July 8, 2009, 5:42 pm

once you go mac you never look back

Comment from abercrombie
Time: September 7, 2009, 9:40 pm

Thanks for sharing informations.Looking forward to more stuff.

Comment from Madeleine Tarlton
Time: September 19, 2009, 9:26 am

Beitrag * lol: P

Comment from utahnix
Time: September 21, 2009, 6:59 pm

OS X has some great things about it, but not all of us think it’s the cat’s meow. OS X is no more *the* OS than XP, Vista or 7 is. It’s a choice. Nothing more – at least in my opinion.

I like that OS X was originally built atop many open components – i.e. CUPS, KHTML, BSD, Samba, etc, etc… but I don’t like how Apple has caked a thick, proprietary layer atop it.

In my mind, the question is… is OS X really open, or very closed? Both? Neither? It’s hard to say, IMO.

While I will give Apple cudos for realizing that open-source code is high-quality stuff, and that it generally does the job really well, I find many of their marketing claims a bit hypocritical. The so-called “Redmond, start your photocopiers” bit they did when Tiger was released was particularly hypocritical. Copying ideas (Microsoft) is one thing… copying source code, line by line (Apple), is another.

And the debate on security… well, is debatable. There is no way to conclusively prove what OS is more secure, regardless of what opinions may exist on either side.

The way I see it, a lot of the best features from OS-X (IMHO) came from the OSS community, not Apple. And Microsoft, they just buy their competition’s products and then slap MS logos on them… or litigate the competition out of existence.

And Linux… well, Linux isn’t for everyone either. It can be hard to configure, and getting software to install isn’t always a walk in the park, especially when you run into dependency problems. Hardware support (thanks to cheap hardware and companies that refuse to play nice) can be tricky. But it’s transparent, and that’s why I like it. But then again I don’t expect any of you to agree with me. I believe there is no such thing as “best” per-se.

I suppose I see Apple and Microsoft as players in a large game of economics… where either will take whatever control of the market they can get, and will do whatever they can to get it, whether it’s good for the consumer or not. I think both companies have had their share of hypocrisy.

And to be honest, companies like Novell and RedHat want their share of the pie and will do almost anything to get it as well. But I think Apple and Microsoft are worse.

That’s my two cents. I’m sure there will be rebuttals to my comments. I’m expecting it.

Comment from tripleX
Time: December 18, 2009, 4:58 pm

I like my tv, radio, dvd-player, my fridge, my cooker. Very useful. But I love my car and I love my Mac.

Pingback from links for 2010-01-12 « Where Is All This Leading To?
Time: January 12, 2010, 5:35 pm

[...] What happens in the Mac OS X boot process? – OS X Daily (tags: howto unix documentation blog mac software startup system troubleshooting geek osx tutorial reference article macosx administration tips tech technology sysadmin hardware apple boot kernel process technical x os internals booting) [...]

Write a comment






January 22nd, 2007