2

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?

Avio
  • 957

1 Answers1

4

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
jlliagre
  • 14,369