20 August 2006

Ignore the pkgsrc disk image instructions

The pkgsrc distribution suggests (and offers tools for) making a fixed-size disk image for OS X and Darwin users. This not the best approach with OS X 10.4 and later.

The following command line incantation can create a resizable HFS+ disk image that is case-sensitive and will grow to fit what you need:


hdiutil create -fs HFSX -fsargs "-c c=64,a=16,e=16 -s" -volname pkgsrc -type SPARSE -stretch SizeOfYourDisk -size SizeOfYourDisk -ov /SomewhereOnYourDisk/pkgsrc


You can avoid silliness with your PATH by adding symlinks:


ln -s /Volumes/pkgsrc/pkg /usr/pkg

ln -s /Volumes/pkgsrc/pkgsrc /usr/pkgsrc

ln -s /Volumes/pkgsrc/pkgdb /var/db/pkg


You can compact this image later to reclaim disk space with:


hdiutil compact /SomewhereOnYourDisk/pkgsrc.sparseimage


You can later use hdiutil resize if you move it to a disk that is a different size. Mounting can also likely be automated to a large degree, maybe the lazyweb can chime in with ideas along those lines.

Update: Don’t, for the love of your files, put the disk image inside a FileVault home directory (or any other sparseimage disk image). I had to borrow a PowerPC Mac and buy a copy of DiskWarrior to get my files back. DiskWarrior apparently doesn’t work with ICBMs yet.

3 comments:

Anonymous said...

Excellent, just what I needed! Thanks.

As for the automatic mounting, you can just put the disk image into users login items and it will be automatically mounted on every boot/log in.

Anonymous said...

Recent comments seems to suggest that pkgsrc is able to handle the case insensitivity of OS X now (although) I would imagine there are certain packages such as mysql that still may not work. However, I haven't followed this up myself and still use a disk image.

Anonymous said...
This comment has been removed by a blog administrator.