Stay on Top of Enterprise Technology Trends
Get updates impacting your industry from our GigaOm Research Community
I normally avoid anything that looks like tech support in my entries here, but this may verge on an exception. Bear with me, and I’ll explain.
I rebooted my Macbook Pro about four days ago, and lo, to my surprise, the icon for my boot drive had vanished. I was, too say the least, slightly perturbed. (To the right, the culprit.)
I tried all the quick-fix things – changed what showed in Finder, tried to get it back through Finder – it was gone there too – and finally, I sucked it up and called Apple. Three calls to Apple – and two instances of being hung up on – a clean install of Leopard, and multitudinous Google searches later, I had found two things: a lot of other people were having these issues, all starting about the same time as mine, and, more importantly, a solution.
So first, the solution, and then the explanation of what it is, what it does, and what that means for all of us Mac users.
To get your startup drive back, you need to run two Terminal commands. One of them requires that you have an Administrator password. I’d generally try to give you a solution that didn’t require Terminal, given some peoples’ squishiness about that, but I can’t find another frontend to this. (There’s an Applescript running around, but it doesn’t work, really.)
xattr -d com.apple.metadata:kMDItemFinderComment /***
In this case the *** signifies the name of your missing drive, as this command will work for any drive. If you want your startup drive, all you need is the slash.
sudo chflags nohidden /*** Same deal with the asterisks, though in this case, another important modification is that it doesn’t need to be run as sudo unless you’re running it on your root drive.
Log out and/or restart, and your icon should be back to stay.
Now, what that all means. As it turns out, the culprit in all this is a simple metadata flag, the hidden flag. This is the same flag that hides the .DS_store files and other things that you’d rather not see floating about your operating system all the time. The problem, in this case, is a change in how Leopard handles that flag, and metadata in general.
Leopard marks a very interesting shift in how Apple’s chosen to deal with the increasing amounts of complicated metadata that we’re all generating. In past years, this has been stored in .DS_store files, for the most part. Tiger added the xattr function family and API’s to play with some, and some people, namely Marquis Logan and John Siracusa, then wrote up some nice little tools that made this accessible to all of us.
In Leopard, there is now a native command for this. There are four flags to the xattr command, at least so far as I’ve been able to tell. (There is no man page for this, but -h works.) They are -l, -p, -w, and -d, and all of them are written out as xattr -flag file [file path]. -L lists the names of all extended attributes on the file. -P, used with -l, prints them. -W is written out as xattr -w attribute_name attribute_value file [file path], and changes the chosen value to whatever you specify. -D, the important one for the above command, simply deletes all extended attributes. The first command, then, deletes all the extended attributes on the given file. The com.apple.metadata.kMDItemFinderComment contains, among other things, the flags for drives in Finder.
The second command, the chflags command, resets the hidden flag on the given file. Two different methods of getting at two different types of metadata, in essence. The second command is found in a couple of places if you google this, but it by itself doesn’t keep the job done. Without the xattr command, the hidden flag resets every time Finder does.
Now, how this happens? I don’t know. I’m working on that – but I suspect that Apple may be too. And in the meantime, I’ve already found some neat things people are doing with it now. Anyone for a way to kill that annoying ‘this program has been downloaded from the internet’ message?