Sunday, February 07, 2010

How to hide Volume from user on Mac OS

This theme is not new for Mac OS staff. Have a look on such situation - you have a public Mac with two or more hard drive volumes on it and you wanna reserve one of them for technical purposes. That means you want to rename one hard drive volume to BackUP and use it for backups only. The problem is that if you do this it will be visible for any user on this Mac and sure they definitely will write own files there.
There is a way to protect it by permissions, but clear that better don't show it at all. No drive - no questions.
Let use Mac way for it.

In console there is a program 'chflags' It allows to hide or unhide any files or folders on your Mac OS file system. Have a note - this exist for 10.5 (Leopard) or 10.6 (Snow Leopard) versions only. The 10.4 (Tiger) has other system. OK, back to Leo.
Rename volume we want to use to BackUP and go there in finder:
And we see that all is visible. Then fire up the Terminal and do:
$ cd /Volumes/
Check the folder flags by:
$ ls -lO
And hide the BackUP volume by:
$ chflags hidden BackUP
Now we see our volume disappear. To bring it back give command in Terminal:
$ chflags nohidden BackUP
For Tiger there is no 'chflags' program in system. SetFile replace the 'chflags' on Tiger. The command will look like:
$ SetFile -a V BackUP
To roll it back:
$ SetFile -a v BackUP
To find the SetFile program there you need Developer tools installed. But I've got the good news. The SetFile exist in Tiger updates and may lay on your disk already. Just find it and copy to /usr/local/bin for future use.
To do it use locate command in Terminal. Before you need to refresh the locate database by this command (input your password):
$ sudo /usr/libexec/locate.updatedb
Then give:
$ sudo locate SetFile
Create directory if not exist:
$ sudo mkdir /usr/local/bin
And copy it by:
$ sudo cp -v yourSetFilePlace /usr/local/bin
Have a note, this method is not secure your files. Use always encryption for it. This method only hide your BackUP data from non clever user usage.
Happy hiding. ;)

No comments: