How to install FreeBSD 9.x using RAID 1 and BSD labels from scratch.
Hopefully the information presented here will be able to assist with the installing of FreeBSD using the above configuration. The beginning point requires a copy of the latest release version of FreeBSD (in this case 9.2). Start the installer as normal and follow the prompts until the partitioning screen appears. At this point, choose Shell (as seen on the screenshot below).
At the prompt screen, the existing partitions and metadata relating to previous disk mirroring needs to be deleted:
Now that the partitions on both disks are destroyed, confirm that any mirror metadata is also deleted:
The gmirror application may baulk at this point and display an error message. If this is the case, then there is no mirror metadata that needs to be deleted. Now the mirror with the two new disks needs to be created. Firstly, gmirror is loaded into memory to achieve the RAID 1 array:
Once the gmirror application is fired up, it’s time to add the two drives to the mirror array:
Now the mirror is created and the mirror drive needs to be partitioned for it to boot and provide redundancy. MBR and BSD label partition tables can now be created on the mirror drive. This is achieved by issuing the following commands:
With the MBR partition table created, it’s now time to create the BSD label partition tables that will be used by the system. The sizes for the various partitions that will be created are based on the following guidelines:
/ 4 to 8 times the installed system memory.
swap 2 to 4 times the installed system memory.
/var 4 to 8 times the installed system meomry.
/tmp 2 to 4 times the installed system memory.
/usr the balance of the free hard disk space.
Remember that these are guidelines and NOT rules. Now comes the creation of the BSD label partition table and that is done by executing the following at the command prompt:
The partitions have been created on the mirror drive. The mirror drive is made bootable by installing the bootcode in the MBR, setting it as the active slice and installing the bootcode in the BSD label:
The filesystems on the mirror need to be formatted (with soft updates enabled):
Now that the various partitions have been formatted, the partitions need to be mounted prior to FreeBSD being installed on the mirror drive. But first the necessary directories need to be made in the /mnt directory, for the partitions to be mounted and finally the /etc/fstab file is created that the system will use to boot with:
Now the /etc/fstab file is created using the following information below:
The necessary directories have been created and the relevant partitions have been mounted for FreeBSD to be installed on the mirror drive. With this done, now it’s time to install FreeBSD:-
Continue with the rest of the installer until the following screen appears:
At this point select Yes and the installer will drop into shell mode where the last tweaks are done to the system to boot from the mirror drive:
That is the installation of FreeBSD on a mirror drive done and all that is left to do is to reboot the newly installed operating system.
Hopefully the information presented here will be able to assist with the installing of FreeBSD using the above configuration. The beginning point requires a copy of the latest release version of FreeBSD (in this case 9.2). Start the installer as normal and follow the prompts until the partitioning screen appears. At this point, choose Shell (as seen on the screenshot below).
At the prompt screen, the existing partitions and metadata relating to previous disk mirroring needs to be deleted:
Code:
# gpart destroy -F ada0
# gpart destroy -F ada1
Now that the partitions on both disks are destroyed, confirm that any mirror metadata is also deleted:
Code:
# gmirror clear ada0
# gmirror clear ada1
The gmirror application may baulk at this point and display an error message. If this is the case, then there is no mirror metadata that needs to be deleted. Now the mirror with the two new disks needs to be created. Firstly, gmirror is loaded into memory to achieve the RAID 1 array:
Code:
# gmirror load
Once the gmirror application is fired up, it’s time to add the two drives to the mirror array:
Code:
# gmirror label -v gm0 /dev/ada0 /dev/ada1
Now the mirror is created and the mirror drive needs to be partitioned for it to boot and provide redundancy. MBR and BSD label partition tables can now be created on the mirror drive. This is achieved by issuing the following commands:
Code:
# gpart create -s MBR mirror/gm0
# gpart add -t freebsd -a 4k mirror/gm0
With the MBR partition table created, it’s now time to create the BSD label partition tables that will be used by the system. The sizes for the various partitions that will be created are based on the following guidelines:
/ 4 to 8 times the installed system memory.
swap 2 to 4 times the installed system memory.
/var 4 to 8 times the installed system meomry.
/tmp 2 to 4 times the installed system memory.
/usr the balance of the free hard disk space.
Remember that these are guidelines and NOT rules. Now comes the creation of the BSD label partition table and that is done by executing the following at the command prompt:
Code:
# gpart create -s BSD mirror/gm0s1
# gpart add -t freebsd-ufs -a 4k -s 4g mirror/gm0s1
# gpart add -t freebsd-swap -a 4k -s 2g mirror/gm0s1
# gpart add -t freebsd-ufs -a 4k -s 4g mirror/gm0s1
# gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
# gpart add -t freebsd-ufs -a 4k mirror/gm0s1
The partitions have been created on the mirror drive. The mirror drive is made bootable by installing the bootcode in the MBR, setting it as the active slice and installing the bootcode in the BSD label:
Code:
# gpart bootcode -b /boot/mbr mirror/gm0
# gpart set -a active -i 1 mirror/gm0
# gpart bootcode -b /boot/boot mirror/gm0s1
The filesystems on the mirror need to be formatted (with soft updates enabled):
Code:
# newfs -U /dev/mirror/gm0s1a
# newfs -U /dev/mirror/gm0s1d
# newfs -U /dev/mirror/gm0s1e
# newfs -U /dev/mirror/gm0s1f
Now that the various partitions have been formatted, the partitions need to be mounted prior to FreeBSD being installed on the mirror drive. But first the necessary directories need to be made in the /mnt directory, for the partitions to be mounted and finally the /etc/fstab file is created that the system will use to boot with:
Code:
# mount /dev/mirror/gm0s1a /mnt
# mkdir /mnt/var
# mkdir /mnt/tmp
# mkdir /mnt/usr
# mount /dev/mirror/gm0s1d /mnt/var
# mount /dev/mirror/gm0s1e /mnt/tmp
# mount /dev/mirror/gm0s1f /mnt/usr
Now the /etc/fstab file is created using the following information below:
Code:
# vi /tmp/bsdinstall_etc/fstab
#Device Mountpoint FStype Options Dump Pass#
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s1b none swap sw 0 0
/dev/mirror/gm0s1d /var ufs rw 2 2
/dev/mirror/gm0s1e /tmp ufs rw 2 2
/dev/mirror/gm0s1f /usr ufs rw 2 2
The necessary directories have been created and the relevant partitions have been mounted for FreeBSD to be installed on the mirror drive. With this done, now it’s time to install FreeBSD:-
Code:
# exit
Continue with the rest of the installer until the following screen appears:
At this point select Yes and the installer will drop into shell mode where the last tweaks are done to the system to boot from the mirror drive:
Code:
# echo 'geom_mirror_load="YES"' >> /boot/loader.conf
# echo 'daily_status_gmirror_enable="YES"' >> /etc/periodic.conf
# exit
That is the installation of FreeBSD on a mirror drive done and all that is left to do is to reboot the newly installed operating system.