Skip to content

Tag Archives: Mac OS X

Archiving OS X Mavericks tags (and other data) with git


For the last 6 months i’ve been archiving all my paper work (OCR’ing and than trashing it) to a personal documents repository.

There are some document managers out there but every single one felt like overkill to me, so i just stick to a pretty simple directory structure which is enough for me.

Although i need those documents across devices, i didn’t want to use a cloud service to sync them. git does a pretty good job here.

With Mac OS X Mavericks comes a great new feature: Tagging. Certainly we’ve all used tags somewhere on the internet and i really like this kind of taxonomies. It’s way better than a fixed folder structure.

So, i can now tag all my documents without the need for an external program.

But what about sync? Those tags are stored in the extended file attributes of the Mac OS X filesystem (along with other stuff, for example if the file has been download from the web or email). git does not include those extended attributes in a repository so they will be lost.

xattr to the rescue. xattr can dump all extended attributes for all files in a directory and also can write them back.

I use the following pre-commit hook to dump all extended attributes of my archive to a file named .metadata

xattr -lrx . > .metadata
git add -f .metadata

This can be a problem if only tags are modified as nothing will be committed. This can be handled by an empty commit:

git commit --allow-empty -m "New Tags

To restore them i use the following post-merge hook which is also executed after a pull (i’m pretty much doing only pulls on this repository anyway).

#!/usr/bin/env ruby
# Be careful, this can be something you don't want:
# strip all existing extended attributes
system("xattr -cr .")
pattern_header = /([^\0]+): (.+):/
pattern_data = /\d{8} (.+) +\|.+\|/
data, current_file, current_attribute = '', nil, nil
File.readlines('.metadata').each do |line|  
  # collect hex data
  if(m = pattern_data.match(line) and current_file)
    m = pattern_data.match line
    data += m[1].to_s.strip if m and m[1]  
  # starting hex data for a new file
  elsif(m = pattern_header.match(line))
    # we have some data for the current file
    if current_file and data != ''
      system("xattr -wx #{current_attribute} #{data.gsub(/ /, '')} \"#{current_file}\"")
    data, current_file, current_attribute = '', m[1], m[2] 
  elsif current_file   
    m = pattern_data.match line
    data += m[1].to_s.strip if m and m[1]  

This hook is pretty simple and one can surely think of better ways for storing (and / or parsing) the data and add some error handling, but this works quite well for my purpose.

This hook also stores every extended attribute. If you’re only interested in meta tags, than only sync the “” attribute.

Mac OS X Lion loses network connection after sleep


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/” like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

and relaunch the mDNSResponder like so:

sudo launchctl unload -w /System/Library/LaunchDaemons/ 
sudo launchctl load -w /System/Library/LaunchDaemons/

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


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

killall -HUP mDNSResponder

and copy this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
                <string>-w /path/to/restart_mDNSResponder</string>

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.

XML / XSD Schema validation on Mac OS X


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

3 days with Linux


Since Tuesday i installed Debian Linux 4 times on my new Dell Vostro 200.

The choice of hardware was kinda stupid. I thought, well this thing is not a special thingy but plain standard. Well, seems, it isn’t.

The first setback was, that the Debian installer booted from CD-Rom but didn’t recognize it afterwards. Yippie… I had to change the SATA Bios settings from IDE to RAID which means in reality, to AHCI. 2 things changed: Debian can be installed from CD-Rom and the dualboot Windows went nuts, i.e. crashed with a BSOD, even in safe mode. Solution to that was first switching back to IDE mode, installing some Intel driver for RAID thingies (really, there’s no raid in the machine… *sigh*), switch back et voila.

Next thing: The ethernet controller was to new. It’s kinda e1000 but not yet supported in the current testing kernel. The driver can be downloaded at intels site. I’ve chosen to skip network while installation and downloaded a full image. If you want to install from a netinstall image and have no 2nd nic at hand, here you’ll find a precompiled module. The blogs seems well written, but i wouldn’t call the Vostro a bunch of crap. The thing is very low noise, with Windows XP rock solid (at least at my workplace {i actually have two of them, at work and now at home}) and i appreciate the Dell pickup service. Another great howto is presented at the Ubuntu forums.

The next closed source thing i installed where the ATI drivers from here without a problem.

The things that lead to multiple reinstalls where the decision between KDE and GNOME. I just wanted to test them and didn’t want to purge every single package afterwards. In the end i went for GNOME.

So now i have a Desktop with the preinstalled Vista on a one partition and my new all day Debian system on a fully encrypted LVM partition. The later one was really no big deal to create with the Debian installer. The whole filesystem is encrypted except a boot partition and a relatively big space which i wanna spent on virtual machines.

prego stated that i should spent some energy into compiz. I already are accustomed to continuous zoom in the whole desktop, some nice effects and semi transparent windows through Mac OS X, for that to say, but i didn’t want to add non “official” repositories. In the end, i give it a try and followed the instructions here and used the instructions for the xorg.conf from here without that Xgl thingies. What can i say: It works and looks great. The wobbling windows are hilarious :D

For my photo collection i already installed digiKam, which is a great tool.

Next steps are migrating my email from Apple to a local IMAP server. Anyone suggestions which email client to use?

A friend tried to convince me several times to reinstall my Macbook for good but i don’t want to. Things used to work and broke with an OS update. And no, i’m not using *any* of the OS X system hacks. I used to be able to upgrade from release to release (hell, the iMac made it from 10.3.8 to 10.5.1 without a problem) and all of sudden i’m back in windows times: Upgrade and you’re doomed. Suck my dick… I don’t wanna go this path ever again. And then there the recent developments with Apple. I’ve been wearing a t with “Think different” know for about 5 years, i always like their products, the integration of Unix and eyecandy. But the apps are getting worse with every new release the last months. Apples behaviour to make you pay for a simple software upgrade (sarbane oxley my ass…, i’m expecting the first bugfix to be payed because the OS is no abo related model). OS Xs unablity to encrypt the whole volume (it can encrypt your home folder in some silly image file) without external tools (recently, Truecrypt can do this.

Stop. Must… breath… again.

In the end, i think three days without much sleep were well spend.

As before, i’ll keep you updated, if you like :)

From Parallels Desktop to VirtualBox


For backup and testing purpose i keep a virtualized version of my webserver running under Parallels Desktop for Mac on my mac.

Recently Dell had some very convenient offers on their PowerEdge machines and i could barely resist to buy one, but finally, i managed to: cut the crap, i don’t want to have even more boxes standing around at home.

But i was thinking again: Whats better than one backup? Redundant backups :)

So i downloaded a copy of Parallels Workstation to install it on my PC at work. Equipt with a DVD and my image file from Parallels Desktop, i fired up the PC Version and after fiddling around with some pathes i can confirm that the Parallels Desktop 3.x vms are compatible with Parallels Workstation 2.x vms, at least a vm with a Debian OS inside.

But to me, performance was poor. My mac is a 2Ghz Core2Duo Mac Book with 3GB Ram, my Pc is a 2.66 Core2Duo Dell with 2GB Ram and Parallels Workstation was way slower on the PC than unter OS X. In addition: I didn’t want to spend another 50$ for Parallels (i already bought versions 2 and 3 for Mac, should be enough), so i thought about alternatives on my PC running Windows XP as host.

I already knew about QEMU which in contrast to Parallels and VMWare is a processor emulator and not a virtualization tool and therefore must be slower. I recommend the QEMU Manager for Windows Users, as this thingy already contains the kqemu virtualization extension.

Installation is dead simple and to my surprise, it was enough to convert my Parallels extending image with the Parallels Image Tool to a plain disk which i could use without further changes with QEMU.

Debian is very stable against the few “hardware” changes. The only problem i had that Debian wouldn’t find my eth0 device although the Realtek 8139too module was loaded. Solutions: The ethxxx devices are bound to the hardware (mac) address. I could look up the mac address in the Parallels configuration file, add this number in the QEMU config and voila, everything was up and running.

Somewhat complicated is bridged networking with QEMU. First you need the TAP-Win32 driver which is brought to you by the great OpenVPN project. The most simple way to install is through OpenVPN Gui for Windows.

After install add a new TAP device through the startmenu entry and then, the clou: There are some howtos which recommend enable bridged networking through the Internet Connection Sharing facilities of windows but it’s much simpler than that: Under network connections, select your default LAN Connection, the tap device, right click and choose bridge networks.

After that, change the network mode in your QEMU vm from user networking to tap networking and you’re ready to go.

Performance was quite good (at least at Parallels speed) but i guessed, there was room for more so i look for VMWare. Unfortunately, the QEMU image tool qemu-img.exe repeatedly crashed while converting my Parallels Image to the vmdk format so this was a dead end for me.

Although the Parallels image worked fine with QEMU and later on also in our Oracle VM Server as a hw virtualized XEN machine, i was not content and i looked out for VirtualBox which is available under a GPL license without USB support which i don’t need, but is able to use Intel VT-x and AMD-V technology.

I needed to convert the Parallels image from a raw disk format to innoteks vdi format, following the steps explained here.

All the tools mentioned there are also available under a Windows installation of QEMU and Virtualbox. Commands as follow:

qemu-img.exe convert foobar.hdd foobar.bin
VBoxManage.exe convertdd foobar.bin foobar.vdi

For bridged networking unter VirtualBox the same applies as to QEMU without the need for OpenVPN, you can add a TAP device right from within VirtualBox . If you already have the bridged described above, you can add the VirtualBox interface with a right click to that bridge. Also, to have Debian not change the eth number, add the same mac address in the network tap of VirtualBox.

All this said and done, booting the system was blazing fast and also the backup of my Daily Fratze project which is pulled via rsync from my server, runs extremly smooth and i have absolutely no hassle setting up Ruby on Rails, RMagick and MySQL under the Windows “Operating System” but can use Debian or any other distro with a sane environment.

After fiddling around with both VMWare and VirtualBox, i’d prefer VirtualBox over VMWare Server (which is also available for free {i.e. for giving VMWare your personal data}). VirtualBox has less overhead then VMWare Server, is simple to configure and as i said, amazingly fast.

When the OS X version leaves beta, i’ll switch from Parallels on my Mac to VirtualBox, at least for my server live backup, so i can make it redundant with the one some kilometres away (call me paranoid if you like) at my workplaces PC.