Stupid Symlink Tricks

On March 13, 2004, in Final Cut Pro, by peterb

I do all of my work on my laptop. I have an external drive for large projects, but the desire to keep everything on the laptop means that I really only want to spend internal hard drive space on the essentials.

I love LiveType, but I only use it once in a blue moon, generally when finishing a project up. Unfortunately, Apple’s dopey installation program requires that LiveType (like all the Pro apps) be installed completely on the internal drive. Here’s how to route around their bogosity.

All we’re going to do is use the unix ability to have symbolic links from one directory to another allow us to store the most egregiously large directory on our external drive. Symbolic links are created with the ln command.

(I am assuming that your external drive is hooked up during this procedure. For instructional purposes, let’s assume the drive is named external)

  • Install LiveType as normal on the internal drive.
  • Download and install any software updates that are available.
  • Open a terminal window. cd /Library/Application\ Support/LiveType
  • sudo mkdir -p /Volumes/external/Library/Application\ Support/LiveType
  • sudo mv LiveType\ Data /Volumes/external/Library/Application\ Support/LiveType
  • sudo ln -s /Volumes/external/Library/Application\ Support/LiveType/LiveType\ Data
  • That’s it! You’re done. (You could of course just do sudo bash and then issue the mkdir, mv, and ln commands from a root shell, but that violates the principle of being conservative when wearing your root hat).

    You can do this not only with LiveType, but with Soundtrack, and in fact even with iTunes, if you’re willing to accept parts of your collection being unavailable when you’re not tethered to your drive. Note that iTunes goes to greater lengths than most to disallow this technique (in particular, it will actually insist that your “iTunes Music” directory is on a local drive, but you can set up symlinks within that directory for specific artists. I have two little shell scripts to let me migrate data back and forth as I desire. Here’s one:

    % cat offline.sh
    #!/bin/sh
    mv “$1″ “/Volumes/My External Drive/Music”
    ln -s “/Volumes/My External Drive/Music/$1″

    …so from within my iTunes Music directory offline.sh "The Beatles" will migrate the entire Beatles directory to the external drive, and set up the correct symlinks so that I can still access it as needed. Of course, there’s an online.sh to reverse the process.

    One thing of note is that most of the HFS+ savvy applications hate symlinks and do unexpected things when asked to store data in a symlinked directory. So if after migrating data offline you try to add anything to those directories (for example, by ripping another Beatles album, say Let It Be in iTunes), it will end up sticking that in ~/Music/iTunes/iTunes Music/Let It Be rather than in ~/Music/iTunes/iTunes Music/Beatles/Let It Be. It still works, it’s just unpleasant. This means that you should always be prepared to undo your symlinks before installing software updates, for example, lest you confuse the poor lost little Finder.

    I hope this little trick helps you, and be sure to make backups of any unrecoverable data before trying it, lest a careless slip of the fingers (or a mistake on my part!) cause data loss.

     

    3 Responses to “Stupid Symlink Tricks”

    1. Derrick Brashear says:

      I assume a more Mac-centric audience might not realize it; My first thought was to do it exactly this way, because duh, it’s Unix.

    2. Brett Johnson says:

      I have a couple of comments.

      The BSD unix command line utils (like mv) don’t understand HFS resource forks, so they are lost. For a single file, use CpMac. For a whole directory, use ditto (which preserves permissions as well as resource forks).

      Within a volume, mv optimally moves only the directory entries for a file – the actual data remains in its original disk blocks (inodes). However moving across volumes forces the data to be copied, so your no better off than using ditto anyway. However, you can usually avoid the copy step by performing the link in advance of the installation. That forces the installer to put the files on the external device as they are un-archived.

      One way to fool iTunes is to hard-mount another device into the filesystem at ~/Music/iTunes/iTunes Music. This is especially nice, because you can keep a small selection of songs on the laptop for when you are “untethered”. The hard mount at that same directory would then “obscure” the local tunes. Ideally, you could mount using the ‘union’ option, but that would probably seriously confuse iTunes. man mount.

    3. Of course, this is well covered in the manual on page 105 (from memory). A regular alias will work 99% of the time.

      Cheers

      Philip