Troubleshooting Mac OS X Kernels w/ dmesg

The first thing that loads in OS X is the kernel. The kernel is how users interface with hardware and sets the stage for interaction by probing for each driver that needs to be loaded and tracking what is found. The presence of everything about the system is tracked when the kernel loads as well as pertinent boot parameters. Even if you’re booting in verbose mode, most of this probably happens too fast to notice. You might be able to pause it, but you’re still trying to react to things too quickly in many cases. That’s where the dmesg command comes into play, which lets you review and control the messages since the system has booted. The dmesg command also looks at some diagnostic messages after the system is due booting, such as when a new interface is detected. The dmesg command allows for more than what you can see in console, except explicitly for I/O related kernel messages after boot, rather than all the pesky OS stuff you might otherwise see, such as snarky little “spotlight can’t index this or that” kind of errors. Instead, dmesg output is only a few screens, easily readable that focuses on the system hardware & I/O interfaces. Using dmesg is pretty easy. Even if you’ve su’d, you need to run sudo in front of it each time, but there’s no need for any parameters: sudo dmesg You can use -n for the level of errors or -s to constrain the buffer size, but in Mac OS X you likely don’t need to do either as there’s not a ton of information. If you’re looking for something specific, such as information on an AirPort interface, just grep it out: sudo dmesg | grep AirPort Overall, dmesg is helpful for stuff like this: vnic0: promiscuous mode enable failed Apparently, Rajesh Koothrappali couldn’t find any booze… Or this: USBF: 23952.350 AppleUSBEHCI[0xffffff800b7dc000]::Found a transaction which hasn't moved in 5 seconds on bus 0xfd, timing out! (Addr: 4, EP: 2) I had a bad drobo on the system… Which I might have known by the fact that the Finder froze when plugged in. But I always like to see it in the logs. Swap out one drive, message goes away, drobo loads just fine. Have I mentioned recently I’m liking the low end drobos less and less…

LoginHook Bonjour

Want users to be able to use Bonjour at home without having their systems registering with Bonjour when they’re on your network? Many environments have taken to wholesale disabling Bonjour. This can be done by augmenting the LaunchDaemon that invokes Bonjour, that is located at /System/Library/LaunchDaemons. You add a -NoMulticastAdvertisements to the ProgramArguments array. This can be done with the defaults command as so:
defaults write /System/Library/LaunchDaemons/ ProgramArguments -array-add “-NoMulticastAdvertisements”
This can then be undone by writing the contents you want back into the array without the -NoMulticastAdvertisements:
defaults write /System/Library/LaunchDaemons/ ProgramArguments -array /usr/sbin/mDNSResponder -launchd
This is somewhat well documented, initially appearing as an Apple kbase article. However, we should keep in mind that computers, especially laptops, have a tendency to go home with people. Therefore, you may very well want to fire Bonjour back up in the event that your users are not in your environment. Prior to Mac OS X 10.6 (aka 10.5 and below) you could edit the /System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/Kicker.xml file to add a shell script and upon network change it would fire off an event to run some script that you craft. In this case, the script you might run would be a simple look for some variable you decide to key off of and run one of the two above commands based on an if/then keyed off against whether the name has a valid hostname (we’re assuming it does in your network and it does not when not in your network):
if [ $(host | grep -ic “not found:”) > 0 ]; then defaults write /System/Library/LaunchDaemons/ ProgramArguments -array /usr/sbin/mDNSResponder -launchd else defaults write /System/Library/LaunchDaemons/ ProgramArguments -array-add “-NoMulticastAdvertisements” fi
You can also use this as a login hook or the if/then swapped out with one another as a logout hook; customize to your hearts content. You could even run it at boot time or on a scheduled interval, instead of as a login hook. Now, the simple fact is that since this is easy, it’s tempting. But luckily some really smart guys thought of a better way to do this kind of thing (not relying on a login or logout hook). They though that the old 10.5 Kicker was a much better solution and came up with the next best thing, crankd, which allows you to fire off a shell script (maybe one similar to the one here) when the network status changes. Thanks to all involved with this project.

Backing Up and Restoring Subversion

To make a Subversion backup (replacing /repositorypath with your actual repository path and /repositoryname.dump with the path and name of the file you would like to export your repository into):
svnadmin dump /repositorypath > /repositoryname.dump
To then restore the Subversion backup (replacing /repositorypath with your actual repository path and /repositoryname.dump with the path and name of the file you would like to export your repository into):
svnadmin load /repositorypath < /repositoryname.dump