cleanly reading compressed backups

Dan Nelson dnelson at
Sat Oct 28 04:24:13 UTC 2006

In the last episode (Oct 27), Jim Stapleton said:
> I have several disk images, and I'd like to grab files off of them,
> but I'm not sure how.
> I made these images by booting up a linux boot CD (it seemed easier
> than a BSD cd at the time, and the results should be the same), and
> make a backup as such:
> dd if=/dev/sda | bzip2 -z9 | split [forgot the args, basically 1GB
> files that are bsd-backup-(date)-??]
> anyway, without uncompressing them back to disk (it's the same
> slice/partitions as I have now), what's the easiest way to get read
> access to these contents of the files in these backups?

It would be extremely difficult to allow access to arbitrary files from
a backup made like that, without dd'ing the decompressed image to
another disk.  Theoretically a bzip2-compressed file can be randomly
accessed because the dictionary is reset every 900k bytes of
uncompressed data.  You would need to write a geom module that
prescanned the images to determine where the reset points were in the
compressed file, then when read requests come in, decompress the 900k
block containing the region of interest and return the requested block. 
You would then run mdconfig to create device nodes out of your split
files, join them with geom_concat, let your geom_bzip2 module
decompress the resulting joined device, and finally mount the
decompressed device node.  Accessing the resulting filesystem would be
slow, but it would work (in theory).

If you had booted a FreeBSD cd instead (disk 1 of the install CD set is
a livecd) and run a "dump -af - /dev/da0 | bzip2 | split" pipe, you
could have done easy restores with a "cat | bunzip2 | restore -ivf -"
pipe.  Dump's file format includes the file listing at the beginning,
so restore can present you with a file listing first, let you pick the
ones you want, then zip through the rest of the dump file sequentially
to restore the files.

	Dan Nelson
	dnelson at

More information about the freebsd-questions mailing list