How to resize a gmirror on FreeBSD

Lets say you need a partition to be resized, this can be done quite easy if you have a running Geom Mirror.

First, you remove one drive from the mirror by running the following command:

Next you need to prepare the disk ada1 with the new partitions, you can do this by using sysinstall or check here for more info:

Keep one thing in mind, if you use sysinstall. Let it point to the mount points you will create in the next step, DON’T let them point to the active mount points. Your system will become inaccessible if you will.

After you done that, mount the new partitions. I advice you to mount then within a self created structure:

Now you have to copy all files from the gm0 mirror to the new partitions on ada1.

Now edit the /etc/fstab to point to /dev/ada1 instead of /dev/mirror/gm0. Then reboot and be sure you boot from ada1.

This can be chosen with F5 at the bootloader then press F1 to boot.

As last action we have to destroy the old mirror and rebuild the new one. This can be done with the following:

Now reboot but keep in mind that you boot from ada1!

Then insert the ada0 drive.

Wait and your done…

I’m sure there are nicer ways to do this, but for me, it worked fine.