Posts Tagged ‘mac’

WTF, Time Machine?

Tuesday, December 16th, 2008

For a while I was feeling pretty good about making the switch from whenever-I-get-around-to-doing-it backups with SuperDuper to hourly-in-the-background backups with Time Machine. But today I noticed that, even after more than a week, no history shows up when I attempt to “time travel”.

Then I find TS1760: “In the Mac OS X 10.5 Time Machine ‘time travel’ window, past backups may not appear if your computer name includes certain characters.”

The solution is to update to 10.5.5 or later. I’m pretty sure I had done that long before I set up Time Machine.

What the hell?

My computer name was “BR’s MacBook”. I renamed it to “BR MacBook” and, later, “BRMacBook”. So far I have learned:

  • Time Machine does not freak out and renames the root backup folder appropriately.
  • I am still unable to “time travel”.
  • Many people on the Internet have reported the existence of this problem but nobody has claimed to have found a solution to it.

What did I do to deserve this?

UPDATE: Apparently the way to time travel in this configuration is to option-click the Time Machine menu item (or ctrl-click the Dock icon) and select “Browse Other Time Machine Disks”. I found this out by browsing Apple’s discussion forums directly instead of simply assuming that Google knew it all.

Time Machine automatically finds your sparse image

Monday, December 8th, 2008

Yesterday I followed Erik J. Barzeski’s instructions to configure Time Machine to backup to a sparse bundle disk image on my Drobo. I wasted a lot of time trying to figure out how to tell Time Machine to use the disk image and not the whole disk; eventually I discovered that if you just select the disk, Time Machine finds the properly named disk image and automatically uses that. So, if you happen to think like me, I hope this note has saved you a few minutes of confusion.

Other things I’ve learned:

  • Changing the volume name of the backup disk during a backup will cause the backup to fail and start over again. Not a big deal.
  • If you want your backup disk to have a nice looking Time Machine icon, you can find it in the file GenericTimeMachineDiskIcon.icns in the folder /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources.

Creating a RAM disk on Mac OS X

Friday, September 12th, 2008

Here is a pair of shell functions to create and destroy a RAM disk on Mac OS X.

# Creates a RAM disk device, formats it as HFS+, then mounts it.
# parameters: size in megabytes
create_ram_disk() {
	local RAMDISK_SIZE_MB=$1
	local RAMDISK_SECTORS=$((2048 * $RAMDISK_SIZE_MB))
	RAMDISK_DEVICE=`hdiutil attach -nomount ram://$RAMDISK_SECTORS`
	RAMDISK_PATH=`mktemp -d /tmp/ramdisk.XXXXXX`
	newfs_hfs $RAMDISK_DEVICE # format as HFS+
	mount -t hfs $RAMDISK_DEVICE $RAMDISK_PATH
	df -h $RAMDISK_PATH # report on disk usage
}

# Destroys the RAM disk created by create_ram_disk
# parameters: none
destroy_ram_disk() {
	echo "Destroying $RAMDISK_DEVICE"
	df -h $RAMDISK_PATH # report on disk usage
	umount -f $RAMDISK_DEVICE
	hdiutil detach $RAMDISK_DEVICE
	rmdir $RAMDISK_PATH
}

What are they good for?  I use these in any script that needs to write a lot of files that will be thrown away before the script is over.  For example, I keep the contents of my websites in a subversion repository.  When I want to update the site, I run a script which executes:

  1. create_ram_disk 100 to create a 100MB RAM disk
  2. svn export to write the web files to $RAMDISK_PATH
  3. rsync to copy changed files from the RAM disk to the web host
  4. destroy_ram_disk to clean up

I also do this in release build scripts, telling the xcodebuild command to use a temporary RAM disk for intermediate and product files.  Sure, Mac OS X has an excellent disk cache, but why hassle it when you know that all of those files will be deleted soon anyway?