<http://db.tidbits.com/article/9673>
--
Tom Stiller
PGP fingerprint = 5108 DDB2 9761 EDE5 E7E3 7BDA 71ED 6496 99C0 C7CF
It's functionally similar to a disk image, except it can grow in size
as needed, as more stuff gets added to it. It's different from a
sparseimage (which are used for FileVault in 10.3 and 10.4) in that it
doesn't store everything inside a single file; rather, it's actually a
directory (treated as a file in typical OS X bundle fashion) full of
10MiB "chunks", each chunk in a separate file.
This is a big advantage over using a single file: it avoids actual
sparse files [1] and it avoids running into the 4GiB limit on FAT32.
Both of these make it a much better choice when you might be moving it
around. If you've ever tried to move a sparseimage onto a NAS, or
create one there ... well, don't.
The general concept isn't a new one; I've worked with a few products
[2] that use similar tricks to avoid other filesystem limitations.
However, it still looks fairly neat.
-Kadin
[1]: "Sparse" files, generally, are files where the logical and
physical size differ; I'm a little shaky on how or whether HFS
actually implements this or just zero-fills sparseimages. At any
rate, it's one of the things sparsebundles avoid. You basically
can get the benefits of sparsed images without worrying about
whether the underlying FS supports it.
[2]: Off the top of my head, IBM's Content Manager OnDemand and Tivoli
ESM come to mind as working like this, although I think they're
trying to avoid the problems associated with storing and
retrieving lots of small files rather than anything dealing with
sparse files or the 4GiB limit.
How might one use sparsebundle images from the shell? I see
"sparseimages" mentioned in the man page for hdiutil but no examples
follow.
Treat it the same as a disk image. For example:
tms@imac% hdiutil mount -stdinpass /Users/tms/Backup.sparsebundle
Enter disk image passphrase:
Ooops! I should have been more specific -- how would one then CREATE
an empty sparsebundle image? Does this look right?
hdiutil create -srcfolder mydir ~/Desktop/mydir.sparsebundle
Thanks a bunch, Tom.
IMO, the biggest advantage is with backing up. Add a 5MB file to a 10GB
regular disk image, and the whole 10GB disk image needs to be backed up
again. Add the same file to a 10GB sparse bundle, and only one 10MB
band ("chunk" as you call it) needs to be added to the backup.
--
K.
Lang may your lum reek.
I just tried this command and it simply adds .dmg to the output
filename. Upon opening the resulting DMG, I could not, as I was
hoping, add files to the mounted DMG.
As far as I know, sparsebundles can only be created with Disk Utility.
There is *no* way to add files to any form of disk image unless it is
mounted.
You might try typing "man hdiutil", it might save you some time.
The following works. You can change it to suit your needs, but be sure
to read the relevant parts of the man page.
hdiutil create -size 1G -volname foo -fs HFS+ -type SPARSEBUNDLE
foo.sparsebundle
--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Or an application that uses the same subroutines that Disk Utility uses,
such as Carbon Copy Cloner. There's a sparse image option there.
That's perfect, thanks! But now that I look at the man page, may I
ask what the difference is between a bundle and a file as in the two
examples (from the man page):
hdiutil create -type SPARSE -size 1g -fs HFS+ growableTo1g
hdiutil create -type SPARSEBUNDLE -size 1g -fs HFS+ growableTo1g
The man page says the former:
creates a "1 GB" SPARSE image (a 1 GB filesystem in a growable file)
while the latter:
creates a "1 GB" SPARSEBUNDLE (a 1 GB filesystem in a growable bundle)
A sparse image is different than a sparsebundle?
Hey, I used the command you suggested last night -- can I now just
burn that sparsebundle to a DVD by choosing File > Burn "<sparsebundle-
name>" to disk... ?
> On Jul 1, 1:19 pm, Tom Harrington <t...@pcisys.no.spam.dammit.net>
> wrote:
[snip]
> > You might try typing "man hdiutil", it might save you some time.
> >
> > The following works. You can change it to suit your needs, but be
> > sure to read the relevant parts of the man page.
> >
> > hdiutil create -size 1G -volname foo -fs HFS+ -type SPARSEBUNDLE
> > foo.sparsebundle
>
> That's perfect, thanks! But now that I look at the man page, may I
> ask what the difference is between a bundle and a file as in the two
> examples (from the man page):
>
> hdiutil create -type SPARSE -size 1g -fs HFS+ growableTo1g
> hdiutil create -type SPARSEBUNDLE -size 1g -fs HFS+ growableTo1g
>
> The man page says the former:
> creates a "1 GB" SPARSE image (a 1 GB filesystem in a growable file)
> while the latter:
> creates a "1 GB" SPARSEBUNDLE (a 1 GB filesystem in a growable bundle)
>
> A sparse image is different than a sparsebundle?
Yes, a sparse image is a single file which is permitted to grow to a
predetermined size. A sparse bundle is a directory containing a, well,
bundle of files which, when aggregated, can grow to a predetermined size.
The advantage of the bundle over the image is that a change to part of
the mounted image will usually produce changes to a small number of the
component files so that incremental backups can copy less than the
entire image file
>
> Hey, I used the command you suggested last night -- can I now just
> burn that sparsebundle to a DVD by choosing File > Burn "<sparsebundle-
> name>" to disk... ?
Yep.