Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Store Developer docs on a compressed disk image System
I just got done re-installing OS-X (an old Microsoft habit, I guess), and was installing XCode when I realized that almost half of the installation size of XCode is the documentation. I need that documentation, but hate to see 1.3 Gb of my hard drive gobbled up by something that is:
  1. Very compressible
  2. Not demanding on resources
  3. Only rarely used
So I hatched the hare-brained idea to compress it -- and it worked! I've cleaned up the code, so fire up Terminal and do this:
 $ cd /Developer
 $ sudo hdiutil create -srcfolder "ADC Reference Library" 
   -format UDBZ DevLibrary.dmg
That will build the compressed reference library in the Developer folder. Once you are done, delete the "old" reference folder, and make an empty placeholder for later:
 $ sudo rm -rf "ADC Reference Library"
 $ mkdir "ADC Reference Library"
Note: I didn't sudo the mkdir command on purpose, to keep the following Folder Action from prompting me for a password just to open the Developer documentation.

Now once you're done, you can attach to it using hdiutil:
 $ hdiutil attach -mountpoint /Developer/ADC Reference Library 
   /Developer/DevLibrary.dmg
That's it! It's not a read/write volume, but that doesn't seem to be a problem. Be patient while it checksums the file on the first mount, it will go faster once everything checks out.

I also attached a folder action to the /Developer folder that mounts the volume automatically -- that way when I navigate to the Xcode app, it mounts the compressed image for me on the way. Open up Script Editor and cut and paste this code in (don't mind the sloppy code; I'm a script newbie...):

on opening folder this_folder
  tell application "System Events"
    if file "/Developer/ADC Reference Library/index.html" exists then
      -- display dialog "it exists!" --used for testing
    else
      do shell script "hdiutil attach -mountpoint /Developer/ADC\ Reference\ Library/ /Developer/DevLibrary.dmg"
    end if
  end tell
end opening folder

Note that the double backslashes are not typos; AppleScript requires them to handle the backslash properly. Save the script to wherever you want (stock Apple Folder Actions are located in /Library » Scripts » Folder Action Scripts). Control-click on the Developer folder and Enable Folder Actions if they aren't already. Control-click again, select Add Action, and navigate to the saved script above, and you should have an automatically mounting compressed reference library!

[robg adds: Geeklog ate all the backslashes in the original submission, but I think I've put them all back where they need to be -- as a gentle reminder, please use the [code] [/code] tag pair when including code (that will protect the backslashes), and include your email address if posting anonymously, so I can contact you with questions!]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[19,742 views]  

Store Developer docs on a compressed disk image | 29 comments | Create New Account
Click here to return to the 'Store Developer docs on a compressed disk image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Store Developer docs on a compressed disk image
Authored by: mithras on May 03, '07 08:02:30AM

How big is the compressed image?


---
--
mithrastheprophet.net (coming soonish)



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: skrawcke on May 03, '07 08:40:45AM

Mine turned out to be 286.1MB



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: TemporalKnot on May 03, '07 09:03:35AM

Mine is 233.4MB



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: markuswarren on May 03, '07 09:04:06AM
I've just tried a few different settings using Disk Utility with it set to display additional disk image formats as mentioned [url=http://www.macosxhints.com/article.php?story=20050601181738987]here[/url].

ADC Reference Library folder size = 967.4MB (918,113,208 bytes)

.dmg using default Disk Utility "compressed" option = 294.6MB (308,948,797 bytes)

.dmg using Disk Utility "compressed (bzip2)" option = 248.3MB (260,374,766 bytes)

.dmg using Disk Utility "compressed (ADC)" option = 295.4MB (309,748,074 bytes)


[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: markuswarren on May 03, '07 08:34:15AM

I assume you are using the terminal to create the image as the UDBZ (UDIF bzip2-compressed image) option is not accessible by default in Disk Utility (there was a hint a short while ago about enabling a debug mode in DU which does appear to enable a few options when creating new images, and the bzip2 compression is one of them). Apart from getting a smaller size, is there any other reason you're using UDBZ as opposed to the normal compress option you'd find in Disk Utility?

Also, one thing worthy of note is that the UDBZ option is 10.4+ only, so if you have pre 10.4 dev systems that compression option won't be supported.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: marcpage on May 03, '07 09:02:40AM

I used the three types of compression I found in the man page for hdiutil, and here are the sizes you get:

UDBZ 298.5 MB
UDZO 367.1 MB
UDCO 367.4 MB

So that is why he used UDBZ. Of course when you are talking about that much compression, does an extra 70 MB matter that much?



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: IslandDan on May 03, '07 09:09:31AM

This saves about 1GB which has a current cost of under $0.50. That coupled with monthly documentation updates and the added inconvenience hardly seem worth the effort.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: frgough on May 03, '07 11:55:34AM

I'm sure you'll let us all know where we can purchase that $.50 1 GB of disk space and add it to our current hard drives.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: ttt on May 03, '07 01:11:27PM

Are you joking? Just last month I got a LaCie Firewire 250GB drive for $89 at the local MicroCenter without even trying. Looking on Pricewatch shows that you can get an internal 500GB drive for around $100. So the OP was actually being very generous, and you're only really saving about $0.20!



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: lihtox on May 04, '07 07:25:00AM

You miss the point; while 1GB may only cost $0.20, you can't upgrade your current hard drive in 1GB increments. Instead, to upgrade a drive, you have to a) pay $89, b) transfer all your files over, and c) install the drive in your computer. I think this solution is rather more convenient than that.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: ttt on May 04, '07 12:06:16PM

Well you'd be wrong, mainly because you're not considering the long-term costs in maintenance. If you really just need another gig, as I said, a $10 thumb drive is likely to be a better investment than constant micromanagement of "live" compressed images. When it gets right down to it, all of /Developer is under 2GB, too, so the smart money would be to just drop $20 on a thumb drive large enough to hold it all (or stuff in on some unused iPod space) and forget about it when you're not doing development.



[ Reply to This | # ]
Laptop drive prices
Authored by: MtnBiker on May 04, '07 08:34:28AM

These don't look like prices for laptop drives, but for 3.5-in. drives.

---
Hermosa Beach, CA USA



[ Reply to This | # ]
Laptop drive prices
Authored by: ttt on May 04, '07 11:57:13AM

I don't see your point. Even at Flash drive prices of $10/GB you don't even cover minimum wage for two hours of work managing the disk space for eternity. There will unquestionably be future work maintaining the compressed image through system updates that totals more time, multiplied by however much more you make than minimum wage. If you're ever in a real crunch for disk space the best approach is to mass delete the stuff you don't need, not micromanage it.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: corienti on May 03, '07 04:14:08PM

What you're missing is people who have laptops and want to be portable. I have 160GB in my MBP and it's not nearly enough. Now, I have over 2.5 TB in total of external firewire disks, but that's not portable; so I can't relocate that folder to external disk, as they're not connected half the time.

For desktop systems, you have a valid point. But for laptops, this is an *extremely* valuable hint. We can't just cheaply add more internal storage to our laptops.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: ttt on May 03, '07 04:54:34PM

It's not just a question of how cheap internal storage is, but how much it costs to manage "live" compressed storage. With Flash drives dropping below $10/GB, it just is not worth it in terms of value to hunt around compressing odd files here and there only to have a future software update choke just to "save" an odd gig of space. In the balance, it is a heck of a lot cheaper to have an iPod or a thumb drive as supplemental storage rather than endlessly spending time manually managing the contents of your laptop drive.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: corienti on May 04, '07 04:55:28AM

That's a fair point and worth considering.
I come from slightly different viewpoint; I'm a Unix admin and DBA, so for me this kind of thing is quite straightfoward and simple and really not any particular effort at all. The idea had simply never occurred to me before, and I quite like it.

But yes for others who are not as familiar with doing this kind of thing, you're right the cost in terms of "effort" or hassle may not be worth it.



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: ttt on May 04, '07 11:50:42AM
It doesn't much matter how great your skill level is in the effort department. The more you know, the more valuable your time is and the less likely you are to actually save money in the balance by spending time now on compressing it and later on working out the difficulties during system updates. If it takes me even 15 minutes to permanently save a gig of disk space, I'm costing my employer money at even Flash prices! It's fine to do for fun or just for learning or whatever, and I do have some infrequently used stuff on a compressed disk image myself, but the pace of technology has made the practice nearly useless.

[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: TvE on May 04, '07 03:20:04PM

And how much is it worth NOT to have a USB memory stick (that is easy to forget/loose BTW…) hanging out of your labtop, sometimes you sit with the Mac in crowded spaces (sofa/airplane) and then you might break the USB connection (or motherboard)…?



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: TvE on May 04, '07 03:20:40PM

And how much is it worth NOT to have a USB memory stick (that is easy to forget/loose BTW…) hanging out of your labtop, sometimes you sit with the Mac in crowded spaces (sofa/airplane) and then you might break the USB connection (or motherboard)…?



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: djbe on May 03, '07 09:13:45AM
Why don't you add the -noverify option? mounts much faster, like this then:
hdiutil attach -noverify -mountpoint /Developer/ADC\ Reference\ Library /Developer/DevLibrary.dmg

[ Reply to This | # ]
AppleScript formatting question
Authored by: st3phen on May 03, '07 10:59:56AM

I copied'n'pasted the suggested AppleScript into Script Editor. But when I try to "compile" it, I get an error on line 6 (do shell script...) immediately after /Developer/ADC\ stating
"Syntax Error: Expected """ but found unknown token."
(The dialogue's quotes are actually begin-curly-quote + straight quote + end-curly-quote.)

Any tips on this?



[ Reply to This | # ]
AppleScript formatting question
Authored by: djbe on May 03, '07 11:06:08AM
I had to change it a bit to get it to work:
on opening folder this_folder
  tell application "System Events"
    if file "/Developer/ADC Reference Library/index.html" exists then
      -- display dialog "it exists!" --used for testing
    else
      do shell script "hdiutil attach -noverify -mountpoint "/Developer/ADC Reference Library" /Developer/DevLibrary.dmg"
    end if
  end tell
end opening folder
Does anybody know how to mount the image without it showing up on the desktop? (and in the sidebar of finder windows)

[ Reply to This | # ]
AppleScript formatting question
Authored by: markuswarren on May 03, '07 11:27:04AM
the man entry for hdiutil mentions the following:

-nobrowse mark the volumes non-browsable in applications such as the Finder.

You would need to modify the "do shell script" line to the following:


do shell script "hdiutil attach -mountpoint /Developer/ADC\\ Reference\\ Library/ /Developer/DevLibrary.dmg -nobrowse"
The volume won't appear on the desktop, nor in the sidebar as a volume. When you navigate to the path where the mountpoint folder is located, then you will be able to browse and open the files within (or I was able to in my brief test). The volume is read-only at this point though.

[ Reply to This | # ]
AppleScript formatting question
Authored by: markuswarren on May 03, '07 11:17:25AM
The problem is due to the backslashes' in the "do shell script line" not being escaped, thus when it's compiled it gets an error. The line in question should read:

 do shell script "hdiutil attach -mountpoint /Developer/ADC\\ Reference\\ Library/ /Developer/DevLibrary.dmg"
The full script code, with the amended line would be:

on opening folder this_folder
	tell application "System Events"
		if file "/Developer/ADC Reference Library/index.html" exists then
			-- display dialog "it exists!" --used for testing
		else
			do shell script "hdiutil attach -mountpoint /Developer/ADC\\ Reference\\ Library/ /Developer/DevLibrary.dmg"
		end if
	end tell
end opening folder


[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: marcpage on May 03, '07 01:43:20PM

While this may not save much, you can apply similar logic to any place where a large number of mainly text files are stored. For instance, you can use this method, coupled with a shadow file (see the man page for hdiutil) to have most of your mail messages on a compressed disk image (new ones would be put in the shadow file).



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: metiure on May 03, '07 04:07:00PM

could you please elaborate on this, as I am interested?



[ Reply to This | # ]
Shadow file?
Authored by: metiure on May 04, '07 02:42:06AM

Please, can anyone point me to how use a 'shadow' file and a compressed dmg with Mail?
My Mail folder is more than 1,2 Gb, so i may be interested.
Thanks



[ Reply to This | # ]
Store Developer docs on a compressed disk image
Authored by: boredzo on May 03, '07 08:41:04PM

Even better: Rather than mounting the the disk image volume on /Developer/ADC Reference Library, mount it normally, then make an alias to it at /Developer/ADC Reference Library. Then, opening the alias will mount the image automatically.



[ Reply to This | # ]
Doesn't work
Authored by: TGV on May 04, '07 01:30:56AM

That doesn't work (for me). You apparently have to mount it.



[ Reply to This | # ]