ZFS Portable ZFS Disk Images

I'm trying to research what the best approach would be to replicate the SquashFS functionality on FreeBSD. I want to be able to make a create a filesystem, install whatever files, assets, and programs that I need on it, image and compress it, and finally ship it to another machine to mount as r/o. Preferably, I'd like the underlying filsystem to be ZFS, but that's not a hard requirement.

I've considered three options:
  • mdconfig() with GEOM_UZIP() - Looks like I can use ZFS, but is that the 'best' approach?
  • ZFS with `file` vdev - man page says it's "strongly discouraged", not sure how compression works with that.
  • ZFS snapshots that I can send and receive between machines. It's unclear to me how I would mount them on the fly.
 
I don't know about "best" but what seems the easiest to me is using UFS. Just create the image and be done with it:

Code:
root@unicron:/home/peter # dd bs=512 count=80k if=/dev/random of=image.ufs
81920+0 records in
81920+0 records out
41943040 bytes transferred in 2.920721 secs (14360508 bytes/sec)
root@unicron:/home/peter # mdconfig -a ./image.ufs
md0
root@unicron:/home/peter # newfs /dev/md0
/dev/md0: 40.0MB (81920 sectors) block size 32768, fragment size 4096
        using 4 cylinder groups of 10.03MB, 321 blks, 1408 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 20736, 41280, 61824
root@unicron:/home/peter # mount -t ufs /dev/md0 /mnt
root@unicron:/home/peter # df -lh | grep mnt
/dev/md0                   38M    8.0K     35M     0%    /mnt
Can't get much easier than this I think. When done you can optionally compress the image file and then ship it.

(edit) I used /dev/random out of habit but you might want to use /dev/zero.
 
Back
Top