Skip to content

ZFS Expanding zpool

Lucas Holt edited this page Aug 22, 2022 · 1 revision

There are several ways a zpool can be expanded. If you're using mirroring or zraid, adding additional volumes can increase the pool size.

For mirroring, you can replace one disk at a time, let it resilver and then the other disk and expand the pool with larger drives.

What about virtual disks?

For example, say you're using AWS and you have a single virtual disk. You increase the volume size in the AWS console. How do you get the new size to report?

e.g. A disk of 75GB is expanded to 120GB in aws.

Once the AWS console shows the resize is complete, reboot the instance.

On startup, login via ssh and get a root prompt (or use doas/sudo)

Run this command: gpart show

You should see a corrupt volume reported where the resize occurred.

e.g. to recover xbd6, run this

gpart recover xbd6

Next, you must do a resize.

if you only have 1 partition on the volume, do this

gpart resize -i 1 xbd6p1

gpart show

you should see the new size reported now.

Next you need to resize the ZPOOL. Another reboot should work, but you don't have to reboot. Simply do the following zpool online -e poolname diskname

e.g. for pool tank zpool online -e tank xbd6p1

zfs list

You should now see all the space in the zpool.

NOTE: if this is your boot drive, you may have to run the following command before you will be able to make changes. This can be destructive, so be sure to have backups.

sysctl kern.geom.debugflags=0x10