Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can create squashed filesystems with mksquashfs in this way:

mksquashfs dir-1 dir-2 ... dir-n filesystem-on-file.squash -comp xz -Xbcj x86 -Xdict-size 1048576 -b 1024k

mksquashfs provides compression and deduplication of data but is read-only. Now I would like to create a few test filesystems with ZFS with both deduplication and compression enabled.

What is the equivalent command?

share|improve this question
up vote 4 down vote accepted

This will create a 100 MB file on /tmp then a zpool and zfs file system on it with both compression and deduplication enabled:

cd /tmp
dd if=/dev/zero of=zfile bs=1024k count=100
zpool create -O dedup=on -O compress=on filepool /tmp/zfile

The file system is mounted on /filepool and unlike squashfs is writable.

Just copy your files and directories in it and use zpool list filepool to get usage (ALLOC/FREE/CAP) and deduplication ratio (DEDUP).

eg.

# zpool list filepool
NAME       SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
filepool  95,5M  1,50M  94,0M     1%  2.99x  ONLINE  -

To see the compression ratio, use the zfs get compressratio command:

# zfs get compressratio filepool   
NAME      PROPERTY       VALUE  SOURCE
filepool  compressratio  1.37x  -

You can experiment with the various compression algorithms by specifying a non default one while creating the pool, eg.:

zpool create -O dedup=on -O compress=gzip-9 filepool /tmp/zfile
share|improve this answer
    
Thank you, worked like a charm. At the end I created the filesystem with these options: zpool create -O dedup=sha256 -O checksum=sha256 -O compress=gzip-9 filepool /tmp/zfile because I wanted better compression/deduplication. However mksquashfs seems to be much better for permanent archiving, probably because of LZMA2 compression. – Avio Oct 27 '12 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .