Sunday, February 03, 2013


FreeBsd resize VirtualBox disk

I have a FreeBsd 9.1 VirtualBox guest machine I've created with a 10G disk. After installing my usual programs, I've got the not-so-friendly "disk full" message.

What to do:

Resize the virtual disk:

VBoxManage \
  modifyhd "FULL_PATH_TO_VDI" \
  --resize SIZE_IN_MBS
For example:
VBoxManage modifyhd "/home/leonardo/VMS/FreeBsd91/disk.vdi" --resize 20480
This will resize the disk up to 20Gb

Let the system know you have resized the disk:

Boot in single user mode and follow these steps:
# gpart show
=>  34  21942973 md0 GPT          (CORRUPTED)
    34       256   1 freebsd-boot (64k)
   290  21943129   2 freebsd-ufs (10G)
The first thing to note is the "CORRUPTED" label. To fix it just do:
# gpart recover ada0
Now, it's time to grow the 10G partition to fill the whole 20G disk:
# gpart resize -i 2 ada0
gpart: Device busy
If you get the "Device busy" message:
# sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16
# gpart resize -i 2 ada0
gpart resized
Ok, now the partition was resized. The last step is to resize de filesystem on it:
# growfs /dev/ada0p2
Done!, now reboot and enjoy your big disk!.

EDIT: Today I've received a comment on Google Plus by Edward Tomasz Napierała about improvements on FreeBsd 10. Here's the comment:
Note that in 10-CURRENT it's possible to do all this without going single-user.
The 'debugflags' step is also not required.
In 9-STABLE it's possible to resize the filesystem mounted read-write,
but it's not possible to resize the partition.

Hi, just wanted to point you to the following post that works to rezise partitions in RELEASE-9.1
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?