Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.