Removing Time Machine backup directories and other stubborn files
(Try in this order: chmod -R +nw . ; find . -type d -print0 | xargs -0 chmod +x ; find . -type l -print0 | xargs -0 chmod -N ; chmod -R -N . ; chflags -R nouchg .
; then remove all.)
Here’s the approximate incantation:
First, remove all user-immutable flags:
chflags -R nouchg .
Second, make everything readable and writeable:
chmod -R +rw .
Next, make sure all the directories are listable (using the execute bit):
find . -type d -print0 | xargs -0 chmod +x
Remove any access control lists (ACLs):
chmod -R -a# 0 .
For some reason the above doesn’t remove ACLs on symbolic links; remove these ACLs:
find . -type l -print0 | xargs -0 chmod -h -a# 0
Now the subdirectories should be removable.
Note: The chmod -a commands will report lots of files without ACLs; consider piping their output through a grep:
chmod -R -a# 0 . 2>&1 | grep -v ‘No ACL present’
NB: The success of all this seems to depend on having the filesystem mounted with the noowners option (i.e. mount -o noowners…). This can be accomplished with mount(8) or by clicking the box at the very bottom of the volume's ‘Get Info’ box - though note that some volumes don’t offer this switch, even if they can be mounted noowners.
Boot into recovery mode (⌘+R at boot). Use disk utility to ensure proper disk is mounted.
umount disk99 mkdir /Volumes/Name mount -o noowners /dev/disk99 /Volumes/Name
(From Evernote)