Wednesday, November 24, 2010

Move folders that are expected in specific locations - Mac OS X Hints

Move folders that are expected in specific locations - Mac OS X Hints


Move folders that are expected in specific locations
Oct 29, '10 07:30:00AM • Contributed by: michelcolman
Quite a few badly written apps like to create folders in specific locations, and expect them to be there and nowhere else. For example, my ~/Documents folder contains items such as 'Microsoft User Data', 'Steam Content', 'TomTom', etc. Some even create folders in your home directory or worse, at the root level of the hard disk!

Sometimes you can set a different location in the preferences of the application, but sometimes there's just no way. If you move the folder, the application will become hopelessly confused and/or create a new copy where it expects it. You can make these folders invisible, but then you can't easily access them anymore.

To move the folder wherever you want to move it to (for example, into a separate 'User Data' folder), create a symbolic link where the app expects it, and then hide the link.

Unfortunately 'chflags hidden' does not work on symbolic links for some reason, so you have to use SetFile which is installed as part of Developer Tools or can be found in various other locations. Just try it, and if it doesn't work, do an advanced search on MacOSXHints for articles with 'SetFile' in the title. (You might also be able to use the '.hidden' file although that is considered to be deprecated).

So anyway, once you have SetFile, do the following:
In the Finder, drag the offending folder to its new location
Open Terminal, and type ln -s with the trailing space but without pressing Enter or Return
Drag the folder from the new location into the Terminal window.
Drag the old location (the folder where the offending folder used to be located, for example Documents) to the terminal window. The command in Terminal should now look something like ln -s /Users/me/User Data/TomTom /Users/me/Documents.
Make sure the Terminal window is frontmost, and press return to execute the command. You will see the link appearing at the old location in the Finder. It looks just like an alias.
In the terminal, type SetFile -P -a V (with the trailing space) and drag the link (the one with the little arrow that looks like an alias) from the Finder to the Terminal window.
Press enter.
The link is now invisible. To the application, it seems as though the folder is still there in its old location.

Tuesday, November 16, 2010

Fixing Unknown error 0xE800000A in iOS Sync - Mac OS X Hints

Fixing Unknown error 0xE800000A in iOS Sync - Mac OS X Hints

The upgrade to iTunes 10.1 killed syncing my iPad. An 'Unknown error 0xE800000A' dialog was displayed. Searching Apple support, where the problem has occurred before without a fix beyond rebooting the device, and searching for the error on the web also didn't give a solution that worked.

Checking in the Console showed that iTunes couldn't write to a plist file in /var/db/lockdown; the file already existed and belonged to _usbmuxd. A quick Terminal session with:

cd /var/db/lockdown

sudo rm the file name

using the file name of the problem plist followed by a restart cured the problem.

Saturday, November 13, 2010

10.6: Reconnect Time Machine backup after drive swap - Mac OS X Hints

Résumé des instructions:
- Disable time machine
- Install /usr/sbin/fsaclctl out of the Leopard install disk that came with my Macbook Pro, from /Volumes/Mac OS X Install DVD/System/Installation/Packages/BSD.pkg , using whatever pkg extractor you desire (I used Pacifist) to make it work (extract only the single file, not the whole thing!).
- Find UUID of new partition (Disk Utility)
- See UUID of old partition
$ cd "/Volumes/Time Machine Backups/Backups.backupdb/*************’s MacBook Pro/Latest"
$ sudo xattr -p com.apple.backupd.SnapshotVolumeUUID "Macintosh HD"

- Change it to new partition UUID
$ sudo fsaclctl -p "/Volumes/Time Machine Backups/" -d
$ sudo xattr -w com.apple.backupd.SnapshotVolumeUUID XXXX "Macintosh HD"
$ sudo fsaclctl -p "/Volumes/Time Machine Backups/" -e

- Make sure new partition has the same name (Macintosh HD) as the old one

10.5: Reconnect Time Machine backup after drive swap - Mac OS X Hints

This hint is inspired by and uses tricks introduced by the hint Repair Time Machine after logic board changes, and is used for a similar purpose. In this case, I used this hint to re-connect Time Machine after migrating a partition from one hard disk to another one. I know it works with an image copy of your partition.

DISCLAIMER: Do this at your own risk! Have a backup of at least your most important files on a separate medium! Do not attempt this if you are uncertain about any of the consequences or circumstances here! There are no guarantees that the following will work for you!

Start from a different disk if you want to copy the system partition (use the System DVD if necessary). In Disk Utility, select the target disk (which must have been partitioned so your Mac can actually boot from it!), click Restore, drag the target partition to the Target field, and the old partition to the Source field. Don't forget to select Erase Destination, or it will in fact just make a file copy. Progress will then be shown as copying blocks instead of copying files.

The copy will be almost identical to the original -- only the drive ID (UUID) will be different, and that is why Time Machine would try to make a complete backup if we didn't do something to prevent it. I have not tested whether a mere file copy of a partition can be re-connected successfully so that only incremental backups are made. It does seem to work with an image copy, though.

After the image is done, remove the old drive/partition, or otherwise disable it, so that you're not confused by its presence -- all commands that follow will refer only to the new partition, and a change will be made only to a folder in the Time Machine backup.

Important: First, disable Time Machine.

Next, open Disk Utility, select your new partition and press Command-I to display the partition's information. You will need the Universal Unique Identifier value; select it with the mouse, copy it, and paste it somewhere for use later. Then open Terminal and go to the last Time Machine snapshot:

$ cd /Volumes/my_backup/Backups.backupdb/my_mac/Latest
Replace /Volumes/my_backup with the full path to your (new) Time Machine drive/partition, and replace my_mac with the name of your Mac as shown on the Time Machine drive. This directory will hold one (or more) folders, each named after one of your drives or partitions. For safekeeping, display the old partition's UUID before you do anything else -- this is the one that Time Machine has attached to your backups:
$ sudo xattr -p com.apple.backupd.SnapshotVolumeUUID my_partition
Replace my_partition with the name of the partition that you'll be swapping the UUIDs on. The command will print out a UUID, just like the one displayed in Disk Utility above. If the UUIDs are identical (which they won't be, yet), Time Machine will make an incremental backup; If they don't match, it will back up the entire partition again.

So if you are really, really certain that your new partition is in fact just a copy of your original partition, and you want Time Machine continuity, you can reconnect the last backup of your old partition to your new partition by overwriting exactly that UUID with the one of the new partition.

First temporarily disable ACL protection for the backup drive:
$ sudo fsaclctl -p /Volumes/my_backup -d
Whatever you do, do not forget the matching command below to re-enable it again!

Next, and this is the critical step, overwrite the UUID with the UUID you have copied from Disk Utility above (the UUID is represented by the X's in this example):

$ sudo xattr -w com.apple.backupd.SnapshotVolumeUUID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX my_partition

Now re-enable ACL protection for the backup drive:
$ sudo fsaclctl -p /Volumes/my_backup -e
Now you can re-enable Time Machine, and it should recognize your new partition as the same as your old one, and only make an incremental backup. When the motherboard of your Mac has changed, proceed as described in the original Repair Time Machine after logic board changes hint.

[robg adds: I haven't tested all of this hint, only the bit about reading the UUIDs off the backup drive, which worked as described.]

NOTE FOR 10.6 Snow Leopard
fsaclctl does not exist in Snow Leopard. Solution: Install /usr/sbin/fsaclctl out of the Leopard install disk that came with my Macbook Pro, from /Volumes/Mac OS X Install DVD/System/Installation/Packages/BSD.pkg , using whatever pkg extractor you desire (I used Pacifist) to make it work (extract only the single file, not the whole thing!).

Show Hidden Files | Mac Tricks And Tips

Show Hidden Files | Mac Tricks And Tips:

Defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Monday, November 8, 2010

How to fix a Time Machine hangup - Mac OS X Hints

How to fix a Time Machine hangup - Mac OS X Hints

Time Machine, while it does have a very usable interface, is inclined to get stuck sometimes.

Occasionally Time Machine seems to be stuck, but isn't really. When you first do a backup, or when you haven't backed up to a particular disk for ages (perhaps if you have been away on a trip), it can spend several hours 'preparing'. You can tell it is preparing because when you open the Time Machine preferences there is the little barber pole saying 'Preparing.'

The essence of the solution is to open up the backup media and find the file ending in '.inProgress' and then deleting that file. This will be on the backup volume inside the Backups.backupdb folder, and then in the subfolder for the machine and volume which was being backed up at the time of the hangup. These folders may be inside of a Sparse Disk Image if the backup goes to a Time Capsule or other network based backup volume. After rebooting the Mac Time Machine can then startup normally and perform its operations.

For more details and some screenshots see my blog.

[crarko adds: I haven't tested this one. It's worth it to read the blog entry and pay attention to the caveats and the screen shots contained therein. I've been fortunate to not have any problems with Time Machine, but I've had clients who experienced the hangup using a Time Capsule or an Xserve based backup.]