Synopsis #
Increasing a virtual disk does not necessarily enlarge its GPT partition or ZFS pool. Expand these layers in order, then check the space available to the affected dataset.
This procedure covers an unencrypted, single-disk pool whose freebsd-zfs partition is the last partition on a GPT disk. It does not cover mirrors, RAIDZ, GELI, intervening partitions, or shrinking storage. Preserve a restorable backup and console access before changing the disk layout.
Identify the disk and partition #
Record the pool provider and the complete partition layout:
$ zpool status -P zroot
$ zpool list zroot
$ gpart show
$ df -h /
The example below uses pool zroot, disk vtbd0, and its last partition vtbd0p5. Substitute the actual pool, disk, and partition index from these reports. Stop if the provider is encrypted or another partition follows it.
Save the partition table outside the affected disk:
# gpart backup vtbd0 > /path/on/backup-storage/vtbd0.gpart
That file records partition metadata; it does not back up files or ZFS data.
Enlarge the virtual disk #
Use the hypervisor’s supported disk-expansion operation. Follow its requirement for shutting down or rescanning the guest. Do not edit an image with an offline disk utility while the hypervisor has it open.
Inside FreeBSD, confirm the larger disk size before changing partitions:
$ diskinfo /dev/vtbd0
$ gpart show vtbd0
The third diskinfo field is the media size in bytes. If it still reports the old size, complete the hypervisor’s rescan procedure or reboot the guest. Do not proceed by guessing the new sector count.
Expand GPT and the last partition #
After disk growth, GPT’s backup metadata may still refer to the former end of the disk. Recover the metadata to the new end, then inspect the layout:
# gpart recover vtbd0
$ gpart show vtbd0
An already valid GPT can report that recovery is unnecessary. Confirm that the extra free space follows the existing ZFS partition. Resize that partition without supplying a size so it consumes the available trailing space:
# gpart resize -i 5 vtbd0
$ gpart show vtbd0
Do not delete and recreate the partition. Its starting sector and existing contents must remain intact.
Expand the pool and verify writes #
Tell ZFS to use the enlarged provider:
# zpool online -e zroot /dev/vtbd0p5
$ zpool list zroot
$ zpool status -P zroot
$ df -h /
Use the provider recorded from this pool, accounting for any GPT label it uses. growfs is for UFS and is not the expansion command for ZFS.
Confirm that the pool remains ONLINE, its size increased, existing files are readable, and the original workload can write. Repeat these checks after a controlled reboot. If the pool grew but a dataset still lacks space, inspect its quotas, reservations, and snapshot use with Find what is using ZFS space
.