Increase the size of a ZFS pool by replacing disks

November 2017 ยท 2 minute read

The size of a zpool can be increased by replacing all disks with larger ones rather than adding new disks to a pool. Useful when the disk space is running out and the server has no more actual space for additional drives. Simply detach the old HDDs - one at a time - and attach larger HDDs to the pool.

Below is an example of how to replace two disks in a mirror with two new ones. Note that if you actually have room for another disk, use zpool replace instead. Also note that the mirror will need to be resilvered twice.

# Make sure that the autoexpand property is enabled
zpool set autoexpand=yes mypool

# Detach and remove the first old drive
zpool detach mypool 1TB-A

# Connect and attach the first new drive. Wait for resilver
zpool attach 1TB-B 4TB-A

# Detach and remove the second old drive
zpool detach mypool 1TB-B

# Connect and attach the second new drive. Wait for resilver
zpool attach mypool 4TB-A 4TB-B

# Export/import or reboot
zpool export test
zpool import test

# Verify that the zpool has expanded
zpool list

# If the new space is in the "EXPANDSZ" column, expand each disk using 'online -e'
zpool online -e mypool 4TB-A
zpool online -e mypool 4TB-B