This is a quick guide on how to resize your ZFS pool after adding more storage. We won't get too much into the details on how to add more storage to a multi provider ZFS pool or RAID setup (that's a complex subject). This guide will be limited to a single provider (aka 'disk' or volume).
Add storage
It sounds simple but there are so many ways to do it. Take a look at the detailed guide on Resize Existing FreeBSD Root Partition. It contains a few different suggestions on how to perform this action. For the purpose of this guide, we added additional space by expanding the virtual machine volume.
Also note that there are usually two ways to setup ZFS. Directly on the volume without a partition table or on a partition. If you are using a partition with ZFS, be sure the follow the section named Re-size the Root Partition/Slice in the mentioned guide before continuing.
Do Resize
Now for the east part. If auto expand is enabled for your pool, then you are done. Your pool should have automatically resized itself the moment you added space. You can check if this option is enabled by doing:
zpool get autoexpand Data
Replace Data above with your actual pool name. If auto expand was enabled, you may skip down to the next section Verifying.
If auto expand was not enabled, you can enable auto expand using the command below. Replace Data with your actual pool name.
zpool set autoexpand=on Data
Since the pool was not imported with auto expand enabled, you'll have to "tell" it to expand this one time. You could also leave auto expand disabled and simply do this each time you need to resize your pool.
Here's what our sample pool looks like before expanding:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Data 19.5G 17.6G 1.90G - - 63% 90% 1.00x ONLINE -
Now do the expand command. Replace Data with your pool name and da1 with your actual device name. If you are unsure on the device name, a simple zpool status should help solve that mystery.
zpool online -e Data da1
Verifying
Check if your pool has resized itself by doing zpool list.
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Data 19.5G 17.6G 1.90G - - 63% 90% 1.00x ONLINE -
Wait? that didn't work (at least for us in our example). If your ZFS pool is using the volume directly (no partition table) and you simply expanded a virtual disk, it means FreeBSD hasn't updated it's internal values with the additional capacity. This behavior is explained in detail in the full guide Resize Existing FreeBSD Root Partition.
To fix that do (replace da1 with your device name):
camcontrol reprobe da1
...and like magic without any additional action, your pool is now expanded if you decided to enable autoexpand. If you didn't, just re-issue the manual expand command from before.
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Data 39.5G 17.6G 21.9G - - 31% 44% 1.00x ONLINE -
- Log in to post comments