Tuesday, January 16, 2007

Hide a volume in Mac OS X

Yesterday, we saw how to install Mac OS X over multiple volumes, but there is a minor glitch in doing so: all "extra" volumes will appear as different drives in the Finder, which means additional icons on the desktop and its windows' sidebars. I find these items useless: why should I care about a part of the file system being stored in a different partition? (Note that this has nothing to do with icons for removable media and external drives, a these really are useful.)

The removal of the extra volumes from the sidebars is trivial: just right-click (or Control+click) on the drive entry and select the Remove from Sidebar option.

But how to deal with the icons on the desktop? One possibility is to open the Finder's preferences and tell it to not show entries for hard disks. The downside is that all direct accesses to the file system will disappear, including those that represent external disks.

A slightly better solution is to mark the volume's mount point as hidden, which will effectively make it invisible to the Finder. To do this you have to set the invisible extended attribute on the folder by using the SetFile(1) utility (stored in /Developer/Tools, thus included in Xcode). For example, to hide our example /Users mount point:
# /Developer/Tools/SetFile -a V /Users
You'll need to relaunch the Finder for the changes to take effect.

The above is not perfect, though: the mount point will be hidden from all Finder windows, not only from the desktop. I don't know if there is any better way to achieve this, but this one does the trick...

11 comments:

  1. Very cool, I used it for a partition on my firewire drive that I use only to mirror my drive and it worked just fine. sudo SetFile -a V /Volumes/Mirror

    ReplyDelete
  2. I also found that formatting with a leading period will work (if you are installing Developer Tools for just this purpose). Details here:

    http://blatti.net/2007/02/14/invisible-volume-in-os-x/

    ReplyDelete
  3. dblatti: Nice but then... how do you access that volume? I assume it will not appear in any Finder window. Do you set up symbolic links or aliases that point into its contents? (E.g. /Users pointing to /Volumes/.Whatever/Users as in my situation?) Do you only access it from the command line?

    ReplyDelete
  4. Russell EdwardsMay 03, 2007 8:55 PM

    You can remove the desktop icons in the Finder Preferences page, General panel... enjoy! So nice not to have those silly things cluttering my wallpaper.

    ReplyDelete
  5. Russell: I know, but there you can only disable groups of items. I still want to have direct access to the hard disk from the desktop, but wanted to hide a single volume from appearing there. Thanks though!

    ReplyDelete
  6. I have MAC for 2 days and I already figured this out!
    It is simple, right click on the Macintosh HD icon and select make Alias - this will create "shortcut icon"
    Now go to finder, preferences and switch off the Hard disks. The Alias will stays on desktop.
    Sometimes it helps going from Win environment...

    ReplyDelete
  7. well that's some trick! thx a lot!

    ReplyDelete
  8. Nice solution Julio! Thanks.

    ReplyDelete
  9. Great work Julio! I used 'sudo SetFile -a V /Volumes/Backup' to make the drive disappear...now what would I use to make the drive re-appear again? Thank you very much for your help!

    ReplyDelete
  10. Dean: "man SetFile" The answer is right in the description of the -a option.

    ReplyDelete
  11. Awesome, got it...Thanx again Julio!

    ReplyDelete