logo

Blog

I ran my own blog from November 2006 till October 2014. All posts are still online, but I don't have time to update it anymore. Please note that all images and media files have been removed when the backup was moved to a new host in early 2016. Enjoy!

Repairing MacOS X permissions - brute force method

29. may 2013

A few weeks ago I had the problem that my Macbook Pro didn't start up anymore. The grey screen appeared, but the blue background or even the login window never showed up. Booting in safe mode (holding shift when starting up the computer) didn't help either.

The first thing to do is to boot in verbose mode then, by pressing both the Command and V keys when starting the computer. The booting process stopped after launchd came up with some problem with the OS permissions. 

So I booted in SUM (single user mode, press both the Command and S keys when after restarting) and fixed this first. If you can't login in single user mode anymore then you're probably doomed, backup your data and reinstall.

Apparently permissions on some launchd files were not restrictive enough (777 instead of 755) and the OS had some problems with that. After rebooting launchd started fine, but the OS was hanging again after (or while?) checking the network devices.

I didn't have a system DVD that moment, as booting from the DVD and using Disk Utility to repair permissionsmight have helped. So I decided to repair permissions in single user mode using the diskutil command line tool, just to notice that this doesn't work as diskutil is missing some libraries when using it in SUM. But no problem, you can load those libraries manually - just to see that diskutil seems to hang again, and there is no verbose mode :/

The next thing I did was to boot the laptop in target disk mode (connect your computer to another machine using a Firewire cable, press the T key when starting up) and to backup all data. Unfortunately it seems that you cannot repair permissions in target disk mode btw (those features were disabled on my machine at least).

Comparing files on both computers showed that some OS files had bad permissions on my laptop, but there are thousands of files and checking them all manually was not an option as I was quite in a hurry. So I opted for a brute force method to get that thing to work again quickly (although I wouldn't recommend this as a standard method - try to get a system DVD with disk utility if possible, or maybe some other tool...)

Here's what I did (you have to boot in single user mode of course):

mount -uw /

chmod -R 755 /Library

chmod -R 755 /System

shutdown -r now

The chmod commands will take some time as these are huge directories, so be patient.

After the reboot the login window came up again (it took a bit more time then usually), I was able to login and to run the Apple Disk Utility to repair all permissions (this took about 30 mins).

So, if you can't login anymore and nothing seems to work then you may want to try to simply chmod the entire OS directories. Most files should belong to root/wheel, so you may also want to use chown to repair these if required. In some cases you may also need to fix permissions in the /etc directory.

As said, consider everything here as a "last option", and use at your own risk!