我最近创建了一个 ZFS 卷来测试它的压缩能力。我正在将它与 ext4 卷并排进行比较。在创建新卷并打开压缩后,sudo zfs set compression=gzip postgres-zfs
我将一个 ~3GB 的文件从 ext4 卷复制到 ZFS 文件,但该文件在 ZFS 驱动器上的大小完全相同(我曾经ls -alh
看到过这个)。我手动压缩文件以查看压缩应该是什么(我知道有不同的级别,但只是为了大致了解)并且仅使用gzip file
文件大小就减少了一半。我的 ZFS 设置也显示压缩已打开:
# zfs get all
NAME PROPERTY VALUE SOURCE
postgres-zfs type filesystem -
postgres-zfs creation Thu Apr 5 17:17 2018 -
postgres-zfs used 1.54G -
postgres-zfs available 143G -
postgres-zfs referenced 1.54G -
postgres-zfs compressratio 1.34x -
postgres-zfs mounted yes -
postgres-zfs quota none default
postgres-zfs reservation none default
postgres-zfs recordsize 128K default
postgres-zfs mountpoint /postgres-zfs default
postgres-zfs sharenfs off default
postgres-zfs checksum on default
postgres-zfs compression gzip local
postgres-zfs atime on default
postgres-zfs devices on default
postgres-zfs exec on default
postgres-zfs setuid on default
postgres-zfs readonly off default
postgres-zfs zoned off default
postgres-zfs snapdir hidden default
postgres-zfs aclinherit restricted default
postgres-zfs canmount on default
postgres-zfs xattr on default
postgres-zfs copies 1 default
postgres-zfs version 5 -
postgres-zfs utf8only off -
postgres-zfs normalization none -
postgres-zfs casesensitivity sensitive -
postgres-zfs vscan off default
postgres-zfs nbmand off default
postgres-zfs sharesmb off default
postgres-zfs refquota none default
postgres-zfs refreservation none default
postgres-zfs primarycache all default
postgres-zfs secondarycache all default
postgres-zfs usedbysnapshots 0 -
postgres-zfs usedbydataset 1.54G -
postgres-zfs usedbychildren 132K -
postgres-zfs usedbyrefreservation 0 -
postgres-zfs logbias latency default
postgres-zfs dedup off default
postgres-zfs mlslabel none default
postgres-zfs sync standard default
postgres-zfs refcompressratio 1.34x -
postgres-zfs written 1.54G -
postgres-zfs logicalused 2.07G -
postgres-zfs logicalreferenced 2.07G -
postgres-zfs filesystem_limit none default
postgres-zfs snapshot_limit none default
postgres-zfs filesystem_count none default
postgres-zfs snapshot_count none default
postgres-zfs snapdev hidden default
postgres-zfs acltype off default
postgres-zfs context none default
postgres-zfs fscontext none default
postgres-zfs defcontext none default
postgres-zfs rootcontext none default
postgres-zfs relatime on temporary
postgres-zfs redundant_metadata all default
postgres-zfs overlay off default
Run Code Online (Sandbox Code Playgroud)
知道为什么这些数据没有被压缩存储吗?
数据被压缩,只是操作系统本身无法通过普通命令识别压缩,因为文件在您访问时会被透明地解压缩。
在该 ZFS 设置列表中,您会看到一个名为 的条目compressratio
,在您的情况下为 x1.34。这显示了文件压缩的效率(平均):
压缩大小*压缩率=未压缩大小
您还可以看到used和logicalused,它们显示完整池的绝对压缩大小和绝对未压缩大小(尽管 logicalused 似乎与提到的测试文件的文件大小不匹配)。
您可以在此处找到有关这些值的更多信息
我还整理了一个包含所有命令及其输出内容的简短列表:
ls
: 显示文件的未压缩大小,但显示文件夹的压缩大小zfs get used <pool>
: 显示池中所有文件的压缩空间zfs get logicalused <pool>
:显示池中所有文件将使用的未压缩空间zfs get compressratio <pool>
: 显示池的平均压缩率du -h --apparent-size
:显示给定文件/文件夹的未压缩大小du -h
: 显示给定文件/文件夹的压缩大小 归档时间: |
|
查看次数: |
2712 次 |
最近记录: |