ZFS and questionable filesystem size reporting

I’ve been doing some testing around with some various different pool configurations on ZFS with some used SSDs I bought, and was about to settle on a particular config for my use cases, until I realised that my measurements…kind of seem off? Can someone help explain what might be going on so I can figure out whether or not I can trust the numbers?

For background: I’m working with 5-7 1TB (931.51GiB) SSDs for a low heat low activity disk array in my small PC, looking to replace a 2 disk RAID0 that gets really hot. It’s going to have a various number of datasets, but the bulk of it is mostly media, a lot of it for professional subtitling work and video editing. My priority is capacity over performance/reliability, but I don’t want to be forced to rebuild an array if a disk does fail if I can help it, so I’m planning on a raidz1 with cold spares that I can hotplug if necessary (I have 8 of these SSDs in total).

So in an attempt to find out what configuration would give me the best space efficiency, I tried creating 5, 6, and 7 raidz1 pools using ashift=13 (as selected by openzfs), and did some testing with the different compression options on datasets using recordsize=1M with one of the folders I’m moving over.

I’m using du -s here to measure the size of each dataset, but df and zfs list -p also report similar values:

array ratio du -s size algorithm
btrfs stripe 1.0000x 129.915 GiB NONE
- - - -
6z1 1.0389x 125.043 GiB off
6z1 1.1029x 117.791 GiB zstd-3
6z1 1.0712x 121.274 GiB zstd-fast
6z1 1.0685x 121.576 GiB lz4
- - - -
5z1 1.0000x 129.911 GiB off
5z1 1.0613x 122.410 GiB zstd-3
5z1 1.0310x 126.004 GiB zstd-fast
5z1 1.0284x 126.317 GiB lz4
- - - -
7z1 1.0666x 121.799 GiB off
7z1 1.1323x 114.730 GiB zstd-3
7z1 1.1407x 113.881 GiB zstd-19
7z1 1.0997x 118.127 GiB zstd-fast
7z1 1.0970x 118.420 GiB lz4

Based on this, I was leaning on going with a 7 disk array and using zstd-3 because it seemed to shave off 15GiB compared to the size of the dataset on the original filesystem [0]. However, the uncompressed sizes differing between the different arrays do not really make sense to me. I would think they would all be 129GiB.

Then I tried bumping ashift down to 12. There, I noticed something: when it was 13 on the 7z1 array, zfs list reported total available space as 4.96T, but when it’s set to 12 it reported 5.23T (out of 6.36T):

$ sudo zpool create -f -o autotrim=on -o ashift=12 -O acltype=posix -O normalization=formD -O canmount=off -O dnodesize=auto -O compression=lz4 -O setuid=off -O atime=off -O xattr=sa -O overlay=off microcosm raidz1 /dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_*
$ sudo zfs list | grep -P 'microcosm|NAME'
NAME                                  USED  AVAIL     REFER  MOUNTPOINT
microcosm                             646K  5.23T      162K  /microcosm
$ sudo zpool destroy microcosm
$ sudo zpool create -f -o autotrim=on -O acltype=posix -O normalization=formD -O canmount=off -O dnodesize=auto -O compression=lz4 -O setuid=off -O atime=off -O xattr=sa -O overlay=off microcosm raidz1 /dev/disk/by-id/ata-Samsung_SSD_840_EVO_1TB_*
$ sudo zfs list | grep -P 'microcosm|NAME'
NAME                                  USED  AVAIL     REFER  MOUNTPOINT
microcosm                            1.16M  4.96T      307K  /microcosm
$ sudo zpool list -v microcosm
NAME                                              SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
microcosm                                        6.36T  1.59M  6.36T        -         -     0%     0%  1.00x    ONLINE  -
  raidz1-0                                       6.36T  1.59M  6.36T        -         -     0%  0.00%      -    ONLINE
...

For the 5z1 array, it pretty much stayed at 3.6T (out of 4.55T). What would happen if I remade the different datasets again?

array ratio du -s size algorithm
btrfs stripe 1.0000x 129.915 GiB NONE
- - - -
5z1 1.0004x 129.861 GiB off
5z1 1.0625x 122.273 GiB zstd-3
5z1 1.0316x 125.923 GiB zstd-fast
5z1 1.0291x 126.237 GiB lz4
- - - -
7z1 1.0126x 128.294 GiB off
7z1 1.0758x 120.752 GiB zstd-3
7z1 1.0443x 124.392 GiB zstd-fast
7z1 1.0418x 124.701 GiB lz4

The datasets on 5z1 seem to retain similar sizes as in the earlier table, but the 7z1 datasets all grew in size, as if to use up the extra ~300GiB (the 4.96 to 5.23 reporting change)? So…I’m not really sure I’m getting as much of a benefit as the “15GiB” savings from earlier would indicate. Does anyone have any insight about this? Does using 5 or 6 data disks as opposed to 4 (multiple of 2) in raidz1 just result in this behaviour/is it something I should avoid for reasons other than failure scenarios?


Something to note is that, even with wildly differing reporting sizes, the compression ratios are still pretty much the same compared to their supposed uncompressed sizes in each configuration, which is something I guess I would expect.

array ratio du -s size algorithm
6z1 1.0000x 125.043 GiB off
6z1 1.0524x 118.814 GiB zstd-1
6z1 1.0566x 118.344 GiB zstd-2
6z1 1.0615x 117.791 GiB zstd-3
6z1 1.0655x 117.346 GiB zstd-5
6z1 1.0662x 117.272 GiB zstd-10
6z1 1.0694x 116.920 GiB zstd-19
6z1 1.0310x 121.274 GiB zstd-fast
6z1 1.0285x 121.576 GiB lz4
- - - -
5z1 1.0000x 129.911 GiB off
5z1 1.0612x 122.410 GiB zstd-3
5z1 1.0310x 126.004 GiB zstd-fast
5z1 1.0284x 126.317 GiB lz4
- - - -
7z1 1.0000x 121.799 GiB off
7z1 1.0616x 114.730 GiB zstd-3
7z1 1.0695x 113.881 GiB zstd-19
7z1 1.0310x 118.127 GiB zstd-fast
7z1 1.0285x 118.420 GiB lz4

[0]: it’s actually compressed there, too, but du seems to report the actual, uncompressed size, according to the output I got from compsize. tbh I feel like this should be normal behaviour, but… (du --apparent-size does report the actual size in all the tested configurations, though)

Bump for the evening NA folks. Any thoughts?

For the time being, I guess I’m going to move forward with the 7 disk RAIDZ1 setup and deal with the funky reporting, but I can always come back to this and recreate my array if indeed it’s problematic (from like a overhead or disk durability/health standpoint).

I think raidz2 (warm spare?) might be better.

What drives are you using, are you planning to run the array >80% full most of the time? (having a fresh drive might make a difference if you keep drives full to the brim and have a write intensive workload and drives are stupid drives without PLP and with a low DWPD rating)


du should sum up the sizes of files and directories.

find . -ls | awk '{sum+= $5 } ; END {print sum}'

might be useful.

In ZFS, predicting space used and space left can get arcane very quickly.

I can’t really help you with that, but this new calculator/explanation might be helpful in understanding what’s going on: OpenZFS Capacity Calculator

This array won’t have a write intensive workload. Generally I’ll just get a video or audio file or two on gdrive per week, download it and open it up in Aegisub for subtitling it over the next day or two, so it’ll mostly be warm storage that’s meant to be read from in low frequency, which is why I think that raidz2 is overkill. raidz2/hot spare would be better, yes, but it feels like a waste and I think I’d prefer to save the last SATA slot on my motherboard for one of my Pro SSDs for any heavier usage needs.

Plus it really isn’t a big deal to hotswap a drive since they’re all basically on the side (or top in this orientation, I guess) of the case, and I’ve already tested hot swapping on all of the drives shown so far:

(HDDs are temporary as I migrate data off of them)

Long term I don’t think I’ll be keeping it above 80% but I might be in the short term (haven’t actually figured out what data I’m copying over so not sure yet) until I can get around to regaining access to my backups server.

Filesizes are column 7 (5 was owner) but yeah this just gives the same output as du --apparent-size (i.e. actual uncompressed size).

Thanks. I was actually using this calculator too (I even mirrored it to my computer so I could modify the first table for easier comparisons for the configs I was interested in) and showed it to a friend who’s been pushing me to use ZFS more. It’s one of the reasons why I leaned towards a 7 disk raidz1 array, since it seemed to indicate higher capacity efficiency with the ashift/recordsize values I was using.

I’ll have to parse through the explanation at the bottom in more scrutiny, but I don’t really remember reading anything on my first skim that would explain the behaviour I’ve been seeing.

1 Like

During creation of the second pool you did not specify an ashift value, ZFS might default to 512Byte sectors then. You lower available size might be a result of ZFS needing more metadata to address the quadrupled number of records.

If you don’t specify an ashift value, ZFS picks it for you (per the source file I linked in the original post), and you can confirm it using zdb. I’d already confirmed it as 13 to see what ZFS selects for these drives when not specifying it. Since it picks something relevant, I just decided to leave it out and trust ZFS here.

$ sudo zdb -C microcosm

MOS Configuration:
        version: 5000
        name: 'microcosm'
<snip>
        vdev_tree:
<snip>
            children[0]:
                type: 'raidz'
<snip>
                ashift: 13
<snip>
1 Like