FreeBSD disk/partition resize – grow on version 7.x or older under vmware ESXi
I’ve tried this on vmware ESXi4.1.
First, shut down the server and enlarge the disk size in the VM config.
Boot into single user mode (press 4 and boot).
Check the block count of the new disk (seen at boot – dmesg) – in our case 419430400.
Update the partition size with fdisk -u /dev/da0
when asked, the start of the updated partition stays the default but the end of the partition you can write the block count of the new disk (419430400). Actual end is less that this size, but fdisk sees that and it suggests the correct number which you can agree on.
you can check if all went well with fdisk -s
. It should be the new block size (little less that the block cound of the disk) – write down this number.
time to update the slice table. This is done by:
bsdlabel -e da0s1
There you edit the number under “# “raw” part, don’t edit”. Funny 🙂 You must change the number here to the block count seen with “fdisk -s” after updating partition.
And then change last line – usually entry “f” which is by default “/usr”. Remember that you can only grow the last partition !!.
Change the first number of the “f” entry with the number which is number of blocks seen via “fdisk -s” minus the offset of the f entry (next number in line).
Save this config.
Now the partition is bigger but the filesystem doesn’t know about it. This is where growfs comes in (was surprised to see that it has been introduced in BSD 3.x).
growfs /dev/da0s1f
and there, you have resized partition.
type CTRL+D to boot into the new – grown partition.
I noticed that this procedure works only for version smaller than FreeBSD 8.
It should work on higher versions but I’ve seen very unstable behaviour – kernel crashes… after using fdisk/diskabel.
For versions FreeBSD 8+ the utility gpart (don’t confuse with gparted !!!t) is used which will be described in next post.
[…] one is easier than previous (FreeBSD 7.x or […]