Skip to content
accelerando

Category Archives: Apple

Mac OS X Lion loses network connection after sleep

05-Jan-12

Sleep related problems have never been a problem for me with OS X (at least the sleep of the machine) since Lion.

Sleep works perfectly fine but after wake my machine has no internet connection anymore, at least it looks like this. It’s only domains that aren’t resolved anymore. It also affects wired and wifi networks. There are a lot of threads in the Apple forums that blame USB drives, Optical drives and the like but this sounds a bit like voodoo.

I found the following working solution:

Edit “/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist” like so:

<?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.mDNSResponder</string>
	<key>OnDemand</key>
	<false/>
	<key>UserName</key>
	<string>_mdnsresponder</string>
	<key>GroupName</key>
	<string>_mdnsresponder</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/mDNSResponder</string>
		<string>-launchd</string>
		<string>-AlwaysAppendSearchDomains</string>
		<string>-DisableSleepProxyClient</string>		
	</array>
	<key>MachServices</key>
	<dict>
		<key>com.apple.mDNSResponder</key>
		<true/>
	</dict>
	<key>Sockets</key>
	<dict>
		<key>Listeners</key>
		<dict>
			<key>SockFamily</key>
			<string>Unix</string>
			<key>SockPathName</key>
			<string>/var/run/mDNSResponder</string>
			<key>SockPathMode</key>
			<integer>438</integer>
		</dict>
	</dict>
	<key>EnableTransactions</key>
	<true/>
</dict>
</plist>

and relaunch the mDNSResponder like so:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist 
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

This fixes to things: The domain resolution described here and the 2 hourly automatic wake from sleep described here.

Update:

It seems that fixed the problem just for that one time. To fix it every wake i use “SleepWatcher” by . Installed as said in the read me, save this file somewhere as restart_mDNSResponder

#!/bin/bash
killall -HUP mDNSResponder

and copy this

<?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>de.bernhard-baehr.sleepwatcher</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/sbin/sleepwatcher</string>
                <string>-V</string>
                <string>-w /path/to/restart_mDNSResponder</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
</dict>
</plist>

to /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist.

and execute

sudo launchctl load -w /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist

This did the trick for me.

Migrate OS X to a bigger hard disk

19-Nov-10

I wanted to upgrade my 2008 MacBook (the aluminium one without firewire) with a bigger and especially faster hdd. I chose a Hitachi Travelstar 7k500. So far, it was a good choice.

This tip does only apply to an HFS+ formatted drive with a GUID partition table.

I already had a (bootable) backup that i create using SuperDuper! But for the migration purpose i wanted a bitwise copy of the old disk, so i used dd. I started the MacBook with the external drive containing the bootable backup and some space for the disk image (as i had no external SATA-USB adapter at hand. The (simple) commands for cloning (and zipping) the internal disk to an image are:

dd bs=128k if=/dev/disk0 | gzip > /path/to/image.gz

The internal disk is in most cases /dev/disk0 but it can vary. The process took about 7hours, i blame my old and slow external disk for that.

After switching the internal disk, which is irritating simple, i don’t know why Apple had to change that in the newer unibodies, i restored the image with

gzip -dc /path/to/image.gz | dd of=/dev/disk0

and rebooted.

The Mac came back immediately without a problem. If you don’t know dd you we’ll be surprised what you see: Your new disk and the partition on it has exactly the same free space as before. This is because dd does an exact bitwise copy of your disk and doesn’t resize the partition.

With the build-in OS X “Disk Utility” (“Festplattendienstprogramm”) you can easily resize the one partition (or create a second one if you like), altough you must boot from the OS X installer disk or as i did, from another bootable backup.

And there was the only problem i had. The german error message says

Partitionieren ist fehlgeschlagen

Beim Partitionieren ist folgender Fehler aufgetreten:

MediaKit meldet: Partition (Tabelle) zu klein

The english message is

Partition failed

Partition failed with the error:

MediaKit reports partition (map) too small.

Bummer. The filesystem itself is resizable but the partition table itself is not. When the original drive was formatted, the partition table was created just for that device.

I found the solution in the Life as i know blog. The author has the same problem while expanding a raid, but the solution can be used without problems for a simple drive. Note that this works only if the drive has just one partition on it! If you try this on your own, i’m not responsible for any dataloss.

Just use the following commands in a terminal (replace /dev/disk0 with your device) (the device must not be mounted while using the commands, therefor like stated above, boot from the installer disk or a backup):

sudo gpt show /dev/disk0
This shows the current partition table. Note the number in the column “SIZE” with the highest value.
Unmount the disk through Disk Utility
The Partitiontable cannot be changed when the drive is mounted.
sudo gpt destroy /dev/disk0
This destroys the current partition table, so be carefull.
sudo gpt create -f /dev/disk0
This creates a new partition table with the correct size for your new harddrive
sudo gpt add -b 409640 -s XXX /dev/disk0
Replace the XXX with the value from size in the first step.
Use Diskutility to mount the disk again. You now can resize the partition or add another
Eventually you need to reboot, but in my case it wasn’t necessary, the partition showed up immediatly. I hower did reboot after resizing it to see, wether the cloning did work.

The cloning did work and i now have a much faster system and more space available.

You can use the process of destroying and recreating the partition table for drives with more than one partition, you must repeat the gpt add step and change the start and end parameter correctly.

Please be sure what you do, when you try to repeat the tipps in this post!

iTunes terminal tipps 2010

13-Sep-10

4 years ago i had a first iTunes terminal tipp, here is a round up (all terminal tipps require Mac OS X):

Invert the iTunes Store links in the list

The littler arrows can either point to the iTunes store or to the same artist or album in your library. Invert their behavior to let them point to your files instead of the store:

defaults write com.apple.iTunes invertStoreLinks -bool YES

Undo this with

defaults write com.apple.iTunes invertStoreLinks -bool NO

Disable them with

defaults write com.apple.iTunes show-store-arrow-links -boolean FALSE

Enable them with

defaults write com.apple.iTunes show-store-arrow-links -boolean TRUE

Restore the horizontal stoplight

Again, Apple messes with it’s own UI guidelines. To restore sanity, use

defaults write com.apple.iTunes full-window -boolean TRUE

Reenable the vertical layout introduced with iTunes 10 through

defaults write com.apple.iTunes full-window -boolean FALSE

Enable half-star ratings

The following will let you rate your songs with half-star ratings (i.e 3.5 stars):

defaults write com.apple.iTunes allow-half-stars -bool TRUE

If you don’t like the fact, that the half-star ratings will round on any i* device, turn it off again:

defaults write com.apple.iTunes allow-half-stars -bool FALSE

XML / XSD Schema validation on Mac OS X

16-Jan-09

I found no fancy graphical xml validator on OS X, but this isn’t a problem.

OS X includes libxml which comes with xmllint.

To validate a xml file against a schema:

xmllint --noout --schema sitemap.xsd sitemap.xml

Absurdistan (2)

07-Aug-08

Behold, here comes the iPhone app all retards have been waiting for:

I Am Rich.

Actually, i think it’s kinda funny, although i guess some people won’t get the joke.

Edit:

Oh and by the way, it seems, you’re never alone as the iPhone keeps iphoning ihome.

ipuke, iguess.

Close
E-mail It