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:
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:
Next, integrate the newly created partition into your existing ZFS pool (commonly named zroot) by running:
where (##) is the partition number returned by the previous command.
To verify the updated partition layout, run:
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
- Q: What does the gpart recover command do?
A: It restores the partition table on the specified disk, allowing FreeBSD to recognize any changes made to the disk size. - Q: What if gpart recover says "da0 recovering is not needed"?
A: This means the partition table is intact and no recovery is necessary. You can proceed with the next steps. - Q: Why do I need to reboot the server after recovering the partition table?
A: Rebooting helps the operating system reload the disk configuration and properly detect partition changes. - Q: What is the purpose of the zpool add command?
A: It adds the newly created partition to the existing ZFS pool (usually zroot), expanding the pool's available storage. - Q: Can I perform these steps on a running FreeBSD server?
A: Yes, but be cautious and ensure you have backups, as disk and partition changes can risk data integrity if done improperly.