I’m new to the forum, but didn’t spot a duplicate based on a quick search. Hopefully this isn’t a FAQ, but it might be one in the future - I can’t be the only person that has this question.
I came here via the NixOS forum. Where I posted effectively this same question - however, I will repeat a summary here.
I’m playing with the recent support for ZFS expansion (zpool attach). Allowing you to add volumes to a RAIDZ array.
I’m playing in a VM - where I can rapidly re-provision things. It’s super nice. So I set myself up with a basic NixOS install - and add 3 blank data drives of 10G each.
These drives appear as /dev/vda /dev/vdb /dev/vdc
So we can make a ZFS RAIDZ array by doing…
$ sudo zpool create dpool raidz vda vdb vdc
$ df -h /dpool/
Filesystem Size Used Avail Use% Mounted on
dpool 20G 128K 20G 1% /dpool
Awesome – 20G of storage on top of 3 x 10G drives - I’m giving up 1 drive worth of space for parity.
Now, because I can quickly burn this to the ground and start again, I’ll do that and get myself back to having 3 x 10G blank drives… This time I’m going to create a very small ZFS RAIDZ with just 2 of the drives, then add a 3rd.
$ sudo zpool create dpool raidz vda vdb
$ df -h /dpool/
Filesystem Size Used Avail Use% Mounted on
dpool 9.5G 128K 9.5G 1% /dpool
No surprise here - but we now add the 3rd drive
$ sudo zpool attach dpool raidz1-0 vdc
$ df -h /dpool
Filesystem Size Used Avail Use% Mounted on
dpool 15G 128K 15G 1% /dpool
What? Why only 15G and not 20G?
Above was my original question - but - I think I solved things for myself, so my question for this forum is “are my conclusions correct?”
Here is what I concluded.
The amount of free space is just an estimate? And that estimate is based on the storage ‘efficiency’ of the ZFS filesystem as originally created.
For me this article was key to understanding what was going on.
By way of explaination, let me use a more extreme example - a 4 x 10G RAIDZ1 - which if created up front, would give me 29G of usable storage. What if we build that same 4 drive array, starting with 2 and then growing to 4 total?
$ sudo zpool create dpool raidz vda vdb
$ df -h /dpool/
Filesystem Size Used Avail Use% Mounted on
dpool 9.5G 128K 9.5G 1% /dpool
$ sudo zpool attach dpool raidz1-0 vdc
$ df -h /dpool/
Filesystem Size Used Avail Use% Mounted on
dpool 15G 128K 15G 1% /dpool
$ sudo zpool attach dpool raidz1-0 vdd
$ df -h /dpool/
Filesystem Size Used Avail Use% Mounted on
dpool 20G 128K 20G 1% /dpool
Now let’s fill that drive up with random data (to avoid compression)
# head -c 35G /dev/urandom > /dpool/big_file
head: error writing 'standard output': No space left on device
# ls -l /dpool/
total 20079455
-rw-r--r-- 1 root root 30762213376 Oct 23 08:45 big_file
# ls -lh /dpool/
total 20G
-rw-r--r-- 1 root root 29G Oct 23 08:45 big_file
Neat - so I have a 20GB capacity filesystem – with a 29GB file on it. ZFS expansion works! You just get a bad estimate on how much free space you have.
Good advice: If you can build the RAIDZ with the right number of disks up front, do so. Expansion does work, but you pay a little bit of a tax because the usable storage capacity goes up when you have more disks, and expansion doesn’t fix that ratio for previously written data.
Any further clarifications, comments, or pointers to FAQs are appreciated. While I think this is correct, I would love to better understand this.
My real world example is that I have 3 brand new 8TB drives, and 1 more 8TB drive being used for parity in another system. I’m deciding do I build out with 3 drives then later expand when I decomission the old system (after copying data) - or run without parity on the old system and have a complete 4 drive array.. decisions, decisions..