# Eking file storage out of macOS filesystems

Usefulness: 🔧 🔧
Novelty: 💡
Uncertainty: 🤪 🤪
Incompleteness: 🚧 🚧 🚧

See also command lines it is tedious to remember for general unix/macOS/BSD/etc commands.

Most of these commands are supposed to be run sudo root, and each may irremediably erase up your data, the data of your friends, the data of your enemies, and you’ll have to go running to the NSA to restore your messages from their backups.

(This was split off from general macOS hacks.)

## How do I rsync between macOS and Linux?

Two problems here:

• macOS seems to present weird encoding normalisation

• macOS desktop filesystems are usually case insensitive and no other modern filesystem is (AFAICT Windows, e.g., fakes it at the user level for NTFS)

Both these can lead to confusing file mangling and potentially data loss.

It seems to work better for me if I do rsync from the non apple machine as far as the (2) stuff goes, in that it then seems not to accidentally duplicate things if renames have happened. I should look into this with more precision.

Then you still need to handle the encoding: --iconv=UTF-8,UTF8-MAC

Putting that together

rsync --delete \
--iconv=UTF-8,UTF8-MAC -avz \
mac.local:/path/to/stuff/ /Volumes/syncdrive/

pro-tip: the iconv options are in order LOCAL,REMOTE, not FROM,TO. (Q: How does that work when both are local or both remote but you want different encodings?)

## Dealing with the transitory, ephemeral nature of data Apple encrypted drives

The best way to make sure nobody reads your confidential data is to make sure you never store it in the first place. Fortunately, Apple has a solution here - FileVault 2! You encrypted something using Filevault 2 on an external drive? Expect the entire disk full of backups to become unusable next time the cable jiggles, and all your data will be, uh… securely deleted for your convenience.

If you like your data, keep at least two copies, on two different disks, to compensate for this convenience.

But you need to take one more step; in periodically reformatting whichever drive most recently corrupted itself and and cloning it from the other drive, you might find that you can’t even erase it. Instead you will get an error unable to delete core storage logical volume.

diskutil cs list
diskutil cs deleteVolume <UUID>
diskutil cs delete UUID-OF-COREVOLUME-GROUP

That doesn’t work? Boot into Linux and nuke it that way.

Or try this cowboy option:

cat /dev/random > /dev/diskBLAH
^C

## Rebuild Spotlight index

Is it working?

sudo mdutil -sv /

No? Turn it off and on again

sudo mdutil -E /

## Mounting foreign files systems

What do you have to do to get foreign filesystems to mount using this week?

osxfuse is maintained once again and offers a variety of filesystems of varied quality. It was awful for, e.g. ext2 for a while there.

• ifuse allows you to talk to iphones.
• adbfs might talk to android devices?

## Burning bootable ISO images to USB

Convert ISO to DMG:

hdiutil convert -format UDRW -o debian-6.0.7-amd64-netinst.img debian-6.0.7-amd64-netinst.iso

Find which disk is which:

diskutil list

Say it was /dev/disk3… Unmount and clobber the right one (careful now) with the new dmg:

diskutil unmountDisk /dev/disk3
dd if=./debian-6.0.7-amd64-netinst.img.dmg of=/dev/rdisk3 bs=1m
diskutil eject /dev/disk3

Doing this without intermediate dmg output left as an exercise for the premature optimizer.