Install FreeBSD 10 on gmirror/gstripe/simple UFS partitions (GPT or MBR)

Option 1. Partition the drives (MBR)

by ross at 05:24:56 on December 30, 2011

Create MBR partition table

If the drive is empty:

# gpart create -s mbr ada1
ada1 created

# gpart show ada1
=>       63  976773105  ada1  MBR  (465G)
         63  976773105        - free -  (465G)

Create MBR slice for FreeBSD

# gpart add -t freebsd ada1
ada1s1 added
# gpart create -s bsd ada1s1
ada1s1 created

# gpart show ada1s1
=>        0  976773105  ada1s1  BSD  (465G)
          0  976773105          - free -  (465G)

If you need to create a slice with exact size (not all the available space) use -s flag to gpart, i.e. "-s 100G".

Create partitions on the first disk

This example shows how to create mirrored, striped and simple UFS partitions. This is just an example, you might want to rethink which partitions will be striped, mirrored or simple.

There will be no ada1s1c (or index -i 3) because partition "c" is a special entry covering entire slice and is not used for filesystem.

Create root (/) partition (will be mirrored, needs ada2s1a):
# gpart add -s 2G -t freebsd-ufs ada1s1
ada1s1a added
Create swap partition:
# gpart add -s 2G -t freebsd-swap ada1s1
ada1s1b added
# glabel label swap0 /dev/ada1s1b
Create /var partition (will be mirrored, needs ada2s1d):
# gpart add -s 2G -t freebsd-ufs ada1s1
ada1s1d added
Create /usr partition (will be mirrored, needs ada2s1e):
# gpart add -s 15G -t freebsd-ufs ada1s1
ada1s1e added
Create /usr/ports partition (striped, 5G x 2 = 10G, needs ada2s1f):
# gpart add -s 5G -t freebsd-ufs ada1s1
ada1s1f added
Create /usr/home partiton (will be mirrored, needs ada2s1g):
# gpart add -s 50G -t freebsd-ufs ada1s1
ada1s1g added
Create /share partition (neither mirrored not striped):
# gpart add -t freebsd-ufs ada1s1
ada1s1h added

Last partition is added without -s (size) so it will cover the rest of the available space.

Install boot code

Install simple MBR boot loader (boots active slice):
# gpart bootcode -b /boot/mbr ada1
# gpart set -a active -i 1 ada1

Or install FreeBSD boot manager:
# gpart bootcode -b /boot/boot0 ada1
# gpart bootcode -b /boot/boot ada1s1

Create partitions on the second disk

Repeat these steps for your second disk (which is ada2 here). This example assumes that there will be no ada2s1h, i.e. the second disk is smaller than the first one and /share will be created on the first disk only.


Trying to follow your instructions but the very beginning, the gpart create -s mbr command fails as mbr type is not supported on FreeBSD 9, it would appear. Recommendations that I have found are to go back to 8.2 to accomplish this. Thankfully I'm on Sparc so that is an option. Any idea if there is a work around?
-- Scott Alan Miller
Tuesday, May 1, 2012, 4:02:59
No idea because it works for me.

This is a spare (empty) disk on one of my home PCs:

# uname -rms
FreeBSD 9.0-RELEASE i386

# gpart show ada0
gpart: No such geom: ada0.

# gpart create -s mbr ada0
ada0 created

# gpart show ada0
=> 63 39177776 ada0 MBR (18G)
63 39177776 - free - (18G)
-- ross
Tuesday, May 1, 2012, 10:19:56
Also, for the MBR option, a lot of people might prefer to mirror the whole disk (this is the reason I'm probably going to use MBR rather than GPT), in which case the process is slightly different, hewing closer to
-- Will
Saturday, March 19, 2016, 1:37:14
-- Максим
Thursday, October 11, 2018, 8:12:55
-- Alex
Thursday, October 11, 2018, 8:16:48