31.07.2025

How to Increase Disk Space in FreeBSD 11/12: Step-by-Step Guide

After expanding the disk size via your control panel, the additional space will not be immediately available to FreeBSD. To make the new disk space usable, you need to perform a few essential operations within the operating system.

First, open the terminal and run it as the root user. The initial step is to restore the partition table on the disk to ensure the system correctly recognizes the new size. This is done using the gpart recover command targeting your disk device (commonly da0). The output of this command will indicate whether recovery was necessary:

If the message states "da0 recovering is not needed," the partition table is already intact.

If it says "da0 recovered," the partition table was successfully restored.

Regardless of the result, it's recommended to reboot the server to allow the operating system to reload the disk configuration fully.

To reboot, run:

shutdown -r now

Once rebooted, you can proceed to create a new partition in the free space using the gpart add command, specifying the partition type as freebsd-zfs and aligning it properly (usually at 4k). This command will return the partition number assigned to the new partition (for example, da0p3). For example:

gpart add -t freebsd-zfs -a 4k da0

Next, integrate the newly created partition into your existing ZFS pool (commonly named zroot) by running:

zpool add zroot da0p(##)

where (##) is the partition number returned by the previous command.

To verify the updated partition layout, run:

gpart show -p

Conclusion

After increasing your disk size via the control panel, it's essential to complete the process within FreeBSD by restoring the partition table, creating a new partition, and adding it to your ZFS pool. Following the steps outlined in this guide ensures that your operating system fully recognizes and utilizes the additional disk space. Always remember to back up your important data before performing disk operations and reboot the server when required to apply changes properly.

FAQ