Where’s My Stuff? Visualizing what you have with GrandPerspective and Disk Inventory X

© 2006 Lawrence I. Charters

Washington Apple Pi Journal, Vol. 28, no. 5, September-October 2006, pp. 10-13.

People lose things on their hard drives all the time. They write a quick letter to the editor, save their masterful work of art, quit the word processor – and have no idea where the letter was saved. Or they transfer dozens of photos from their digital camera – and can’t find where the photos were stored. Or they simply have no idea what is consuming all the space on their hard drive. A week ago it seemed like they had billions of bytes of space; today their Mac claims there is no room at the inn.

The Finder in Mac OS X provides many different ways to view information. You can look at a Finder window by icon, or alphabetically, chronologically, by size, by type of document, by a label, by version, or by comments. You can view thumbnails of photos and other graphics, in different sizes. You can even play sound files and video clips, right in the Finder. And Finder views are customizable; you can add or hide information to suit your taste. Yet people still lose information.

Treemaps

Professor Ben Sneiderman, a University of Maryland computer science, has been studying the visualization of information for decades. Most of his work is devoted to more complex sets of data than the stuff found on your average personal computer, but in 1990 he explored this area, too, and developed what he called “treemaps.” He was “obsessed” with the idea of finding out what was on his lab’s massive (for 1990) 80-megabyte hard disk, and wrote a tool for the Macintosh that produced color maps of the drive usage, with larger files occupying larger blocks of color. This idea turned out to have a ready application to other problems, ranging from stock market valuation to the productivity of professional athletes, but in this article we’ll focus on space utilization on your Mac.

Disk Inventory X

Disk Inventory X, first released in March 2004, was Tjark Derlien’s interpretation of Sneiderman’s treemap visualization, updated by a decade and a half and brought to Mac OS X. Revised several times since then, Disk Inventory X, now up to version 1.0, shows the size of files and folders using a mixture of rectangles, with the sizes relative to the size of the original files or folders, and colored by file type. The opening view gives a graphical look at all mounted volumes, complete with a thermometer-style indication of the total amount of storage space and the amount of space used (see Figure 1).

Figure 1: the opening view of Disk Inventory X, showing a Macintosh volume named Trivet and a Windows-formatted volume, for use with Boot Camp and Mac OS X.
Figure 1: the opening view of Disk Inventory X, showing a Macintosh volume named Trivet and a Windows-formatted volume, for use with Boot Camp and Mac OS X.

Select a volume (or a folder) and Disk Inventory X builds a richly detailed map of the object. Click on a block, and a hierarchical viewpoints to the object using a traditional Finder-style perspective, a color key indicates the type of file and how many files of that type are available, and an information window pops up giving details on the file type, size, date of creation and modification, read-write permissions and other useful details. In our example (Figure 2), the virtual hard disk used by Windows XP (running under Parallels) is highlighted. From the left-hand pane, you can see that this volume has a large collection of videos ripped from (my own) DVDs. Vast amounts of space could be cleared on the drive by getting rid of 22.9 gigabytes of videos, or 15.4 gigabytes of photos, or Windows XP… The window also shows that 404 megabytes are used by GarageBand, which is enlightening; GarageBand has never been used on this machine.

Figure 2: Disk Inventory X is displaying a graphical map of a Mac volume in the center, and the largest block is highlighted. The Finder-like listing shows this is winxp.hdd, and the left-hand key shows this is a Parallels VM hard disk. A floating information window on the right gives detailed information on the block.
Figure 2: Disk Inventory X is displaying a graphical map of a Mac volume in the center, and the largest block is highlighted. The Finder-like listing shows this is winxp.hdd, and the left-hand key shows this is a Parallels VM hard disk. A floating information window on the right gives detailed information on the block.

Play with the menus and you’ll discover you can “zoom in” or out of folders, delving deeper and deeper into your hard drive. You can also turn information on and off, either to get rid of screen clutter or to devote more room to what you are doing. You can resize windows by simply dragging them, allowing you to, for example, take a closer look at clusters of information.

Disk Inventory X has a simple, easy to use interface, excellent help available through the Help menu, and an excellent price: free. The Web site even has a link to a one-minute combination review and how-to on Disk Inventory X, and you can grab the source code, too, if you wish.

GrandPerspective

At first glance, GrandPerspective 0.95 is very similar to Disk Inventory X. Written by Erin Bonsma, it also maps out the contents of a disk drive through rectangles, with the rectangles colored according to file type and sized according to how much space they occupy. Like Disk Inventory, GrandPerspective is also free, and you can grab the source code and roll your own if you are so inclined.

In some respects, it isn’t as polished; for example, if you ask for help from the Help menu, you’re informed that no help is available. On the other hand, the Web site links to GrandPerspective online forums and there is a GrandPerspective mailing list. In all honesty, you really don’t need support; just press buttons and see what happens.

After launching GrandPerspective, you are asked to pick a target volume, and the application then builds a graphical map of your drive. In Figure 3, we’ve created a map of the same drive used previously, and then clicked on the largest block in the map, the virtual hard disk used by Windows XP. At the bottom of the window (probably invisible by the time this makes it to print) there is a line that notes the block occupies 6.56 gigabytes of space, and even shows the path: Users/ lawrence/ Library/ Parallels/ winxp.hdd. By pressing the Show button at the bottom, a Finder window has opened the actual file.

Figure 3: A GrandPerspective graphical map of the same Mac volume shown previously, with the largest block of information highlighted. Along the bottom of the screen (probably all but invisible) the size and path of the file are shown, and a Finder window, triggered through the Show button, shows the file in icon view.
Figure 3: A GrandPerspective graphical map of the same Mac volume shown previously, with the largest block of information highlighted. Along the bottom of the screen (probably all but invisible) the size and path of the file are shown, and a Finder window, triggered through the Show button, shows the file in icon view.

A pop-up menu (Figure 4) allows you to see the same information by depth (how far down it is buried), by directory (the default), by extension (file type), by name, by nothing (everything has the same color) and by top-level directory. Flipping back and forth through the options gives you outstanding flexibility in seeing the same information through different, ahem, perspectives, which is probably where Bonsma got the idea for the name of the program.

Figure 4: GrandPerspective has a number of options for viewing the graphical map, including by depth, directory (the default), extension, name and top-level directory. “Nothing” shows the map without any color coding.
Figure 4: GrandPerspective has a number of options for viewing the graphical map, including by depth, directory (the default), extension, name and top-level directory. “Nothing” shows the map without any color coding.

One recent addition, Mask, allows you to get rid of information. In Figure 5, everything but huge files (larger than 100 megabytes) have been masked out. You can combine different rule sets to show only music files, or only large music files, or medium video files, or only word processing files, or whatever combination you care to specify.

Figure 5: A GrandPerspective mask is used to hide everything but the largest files on the volume. Masks can be combined, and new masks created, allowing for very fine-combed sleuthing.
Figure 5: A GrandPerspective mask is used to hide everything but the largest files on the volume. Masks can be combined, and new masks created, allowing for very fine-combed sleuthing.

OK, and now what?

Powerful tools are nice, especially if they are free. But exactly what can you do with Disk Inventory X or GrandPerspective? The obvious answer: find out what is taking up so much space on your hard drive. Similarly, you can better estimate how much space you might need for digital photos, video, sound files, word processing files, or whatever other use you might have for your computer.

A less obvious answer: diagnose problems. In a recent example, a Pi member reported on our online forums, the TCS (http://tcs.wap.org/), that billions of bytes of hard drive space were disappearing on his laptop, and he didn’t know why. He archived to CD-ROM everything that needed archiving, got rid of files that had no particular purpose, and yet his available space seemed to be shrinking, rather than growing.

By using these two programs, he was able to find the culprit: a badly written driver for a game controller. The game controller was originally designed for Windows, and a driver had been hurriedly (and inexpertly) written for Mac OS X. Even with the driver installed, the controller didn’t work properly, and had been discarded – but the driver was left on the laptop. Several times a second, Mac OS X complained about the driver, and wrote this information into a log file. With roughly 200 bytes of text written to a log file 3,600 times a minute, the log file grew 720,000 bytes per minute, 43,200,000 bytes an hour, a billion bytes a day…every day. Using these utilities, the mysterious log showed up as a large, brightly colored rectangle, and from there it was a short journey to identification and eradication.

Recommendations

Both Disk Inventory X and GrandPerspective are free, so the obvious recommendation is to try both and see which one works for you. Disk Inventory X has a more polished interface, and may be less confusing for novices. GrandPerspective has some unique options that might make it more attractive to more knowledgeable users. They are both gems.

Where’s My Stuff: A text alternative

Since your Mac stores things as simple ones and zeros, the obsessively technically inclined might decry that visualization of binary data is too abstract. To get a more realistic representation, you should be looking at things with the Terminal, unfiltered by the Mac’s nifty GUI interface.

So how do you do this? Fire up Terminal (in the Utilities folder) and type:

du –ak

and you should get a text listing of everything in your home folder, shown in kilobytes, scrolling by too fast to read. Warning: this could take a while, if you have a lot of stuff. To stop the listing, hold down the Apple/cloverleaf key and press the C key. A partial listing will look something like this:

88 ./Applications/Stickies.app/Contents/MacOS
4 ./Applications/Stickies.app/Contents/PkgInfo
4 ./Applications/Stickies.app/Contents/Resources/da.lproj/InfoPlist.strings
8 ./Applications/Stickies.app/Contents/Resources/da.lproj/Localizable.strings
20 ./Applications/Stickies.app/Contents/Resources/da.lproj/MainMenu.nib/objects.nib
20 ./Applications/Stickies.app/Contents/Resources/da.lproj/MainMenu.nib
4 ./Applications/Stickies.app/Contents/Resources/da.lproj/ServicesMenu.strings
4 ./Applications/Stickies.app/Contents/Resources/da.lproj/StickiesDefaultDatabase
8 ./Applications/Stickies.app/Contents/Resources/da.lproj/StickiesDocument.nib/keyedobjects.nib
8 ./Applications/Stickies.app/Contents/Resources/da.lproj/StickiesDocument.nib
20 ./Applications/Stickies.app/Contents/Resources/da.lproj/StickiesHelp/gfx/ax_stk.jpg

To get a listing of literally everything on your computer, and save the result to a text file type in the following two commands:

cd /
sudo du -ak > files.txt

What this does:

  • cd / tells your Mac to move out of your Home directory to the root directory;
  • sudo invokes “super user” mode; after typing this line of text, you’ll be prompted for your name and password;
  • > is a directive to “pipe” the result to a file called files.txt instead of display the result on the screen.

Again, depending on how much stuff is on your computer, this could take a while. The end result will probably be a very, very long text file with a listing of, literally, every single file on every currently mounted volume. On my system, I ended up with a text file 155 megabytes long, with 1,528,422 lines of information, with one file or directory per line.

For most people, GrandPerspective or Disk Inventory X is far more practical, and cost just as much: nothing.

References

Treemaps for space-constrained visualization of hierarchies: http://www.cs.umd.edu/hcil/treemap-history/index.shtml

GrandPerspective: http://grandperspectiv.sourceforge.net/

Disk Inventory X: http://www.derlien.com/index.html