GIT – Step by step instructions for installing 9 with a software 1 mirror using gmirror and GPT partitions

By default gmirror and the GPT partitioning scheme do not get along.  This is because both GEOM (the provider for gmirror) and GPT write meta data at the end of the disk.

Overview

The concept behind this procedure and “work around” is that instead of mirroring the entire disk, you use gmirror to mirror each of your partitions.

The order of these steps is important to avoid corruption.  I would only do this on a clean (and these directions are for that).  If you setup a gmirror after the fact on a running machine the gmirror meta data has to get written somewhere, and if you’ve got a file system on it with data, you risk corrupting it and losing data if it happens to be at the end.

To avoid this we’ll setup GPT, create the partitions, create the gmirror providers and finally newfs the appropriate partition.  This ensures nothing will get corrupted.

Step 1: Boot The FreeBSD Installer

Start the FreeBSD 9 install process as normal.  When you are asked about how you want to partition the disk pick “Shell”:

FreeBSD 9 installer

Step 2: Setup The Partitions

Once inside the shell here are the commands to setup GPT and slice up both .  These examples assume you are doing this on disk ‘ada0’ and ‘ada1’ (SATA), if you are using SCSI you’d do da0, da1:

# ---- Setup 1st disk
#
gpart create -s gpt ada0
gpart add -s 64k -t freebsd-boot -l boot0 ada0
gpart add -s 8G -t freebsd-swap -l swap0 ada0
gpart add -t freebsd-ufs -l 0 ada0

# -- Install boot code to first disk
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

# ---- Setup 2nd disk
#
gpart create -s gpt ada1
gpart add -s 64k -t freebsd-boot -l boot1 ada1
gpart add -s 8G -t freebsd-swap -l swap1 ada1
gpart add -t freebsd-ufs -l 1 ada1

# -- Install boot code to 2nd disk
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1

If the first command gives you a gpart: geom 'ada0': File exists error, you need to erase the existing using

dd if=/dev/zero of=/dev/ada0 bs=512 count=1

Step 3: Setup The Gmirror Providers

Before we proceed we need to have GEOM “re-taste” the partitions so our nice labels show up in /dev/gpt/:

true > /dev/ada0
true > /dev/ada1
# You can check to make sure this worked by running:
ls -l /dev/gpt/

Now we can continue to build the mirror providers for each of our partitions:

# -- Load the geo_mirror KLD
kldload geom_mirror

# -- Build gmirrors
gmirror label boot /dev/gpt/boot0 /dev/gpt/boot1
gmirror label swap /dev/gpt/swap0 /dev/gpt/swap1
gmirror label root /dev/gpt/root0 /dev/gpt/root1

# -- Check status
gmirror status

Step 4: Create And Mount The Root (/) Filesystem

Here we actually format the root filesystem, enabling soft updates (-U).  I also use “-L root” to set the filesystem label but this isn’t needed.  Then we mount the new filesystem in /mnt (which is where the installer expects the target filesystem to be).

newfs -U -L root /dev/mirror/root
mount /dev/mirror/root /mnt

We now need to create the fstab file which will be put into place by the installer:

vi /tmp/bsdinstall_etc/fstab
# Device          Mountpoint      FStype  Options Dump    Pass#
/dev/mirror/swap  none            swap    sw      0       0
/dev/mirror/root  /               ufs     rw      1       1

Exit out of the partitioning shell to resume the setup:

exit

Step 5: Resume The Setup

Continue through the rest of the install as you normally would do.  At the very end when you exit the installer you will see the prompt below:

FreeBSD 9 installer

Pick Yes.

Step 6: Final Configuration

Inside this shell we just need to set a few last minute things to make sure our new OS loads GEOM on boot and also reports the mirror status in the daily report emails.

# -- Make sure gmirror module comes up on boot
echo 'geom_mirror_load="YES"' >> /boot/loader.conf

# -- Enable daily status reporting
echo 'daily_status_gmirror_enable="YES"' >> /etc/periodic.conf

And that’s it! Exit out of this shell:

exit

And reboot!

Print Friendly

Comments

comments

Bài viết liên quan