The mfsBSD has been successfully booted and it should be possible to log in through ssh(1). This section will describe how to create and label slices, set up gmirror for RAID-1, and how to use sysinstall to install a minimal distribution of the FreeBSD operating system.
The first task is to allocate disk space for FreeBSD, i.e.: to create slices and partitions. Obviously, the currently running system is fully loaded in system memory and therefore there will be no problems with manipulating hard drives. To complete this task, it is possible to use either sysinstall or fdisk(8) in conjunction to bsdlabel(8).
At the start, mark all system disks as empty. Repeat the following command for each hard drive:
# dd if=/dev/zero of=/dev/ad0 count=2
Next, create slices and label them with your preferred tool. While it is considered easier to use sysinstall, a powerful and also probably less buggy method will be to use standard text-based UNIX® tools, such as fdisk(8) and bsdlabel(8), which will also be covered in this section. The former option is well documented in the Installing FreeBSD chapter of the FreeBSD Handbook. As it was mentioned in the introduction, this article will present how to set up a system with RAID-1 and ZFS capabilities. Our set up will consist of a small gmirror(8) mirrored / (root), /usr and /var file systems, and the rest of the disk space will be allocated for a zpool(8) mirrored ZFS file system. Please note, that the ZFS file system will be configured after the FreeBSD operating system is successfully installed and booted.
The following example will describe how to create slices and labels, initialize gmirror(8) on each partition and how to create a UFS2 file system in each mirrored partition:
# fdisk -BI /dev/ad0 # fdisk -BI /dev/ad1 # bsdlabel -wB /dev/ad0s1 # bsdlabel -wB /dev/ad1s1 # bsdlabel -e /dev/ad0s1 # bsdlabel /dev/ad0s1 > /tmp/bsdlabel.txt && bsdlabel -R /dev/ad1s1 /tmp/bsdlabel.txt # gmirror label root /dev/ad[01]s1a # gmirror label var /dev/ad[01]s1d # gmirror label usr /dev/ad[01]s1e # gmirror label -F swap /dev/ad[01]s1b # newfs /dev/mirror/root # newfs /dev/mirror/var # newfs /dev/mirror/usr
-F
option used for swap partition. This
instructs gmirror(8) to assume
that the device is in the consistent state after the power/system failure.This is the most important part. This section will describe how to actually install the minimal distribution of FreeBSD on the hard drives that we have prepared in the previous section. To accomplish this goal, all file systems need to be mounted so sysinstall may write the contents of FreeBSD to the hard drives:
# mount /dev/mirror/root /mnt # mkdir /mnt/var /mnt/usr # mount /dev/mirror/var /mnt/var # mount /dev/mirror/usr /mnt/usr
When you are done, start sysinstall(8). Select the Custom installation from the main menu. Select Options and press Enter. With the help of arrow keys, move the cursor on the Install Root item, press Space and change it to /mnt. Press Enter to submit your changes and exit the Options menu by pressing q.
Warning: Note that this step is very important and if skipped, sysinstall will be unable to install FreeBSD.
Go to the Distributions menu, move the cursor with
the arrow keys on the Minimal
option, and check it by
pressing Space. This article uses the Minimal distribution in order
to save network traffic, because the system itself will be installed over ftp. Exit this menu by choosing Exit
option.
Note: The Partition and Label menus will be skipped, as these are useless now.
In the Media menu, select FTP
. Select the nearest mirror and let sysinstall assume that the network is already configured. You
will be returned back to the Custom menu.
Finally, perform the system installation by selecting the last option, Commit. Exit sysinstall when it finishes the installation.
The FreeBSD operating system should be installed now; however, the process is not finished yet. It is necessary to perform some post installation steps in order to allow FreeBSD to boot in the future and to be able to log in to the system.
You must now chroot(8) into the freshly installed system in order to finish the installation. Use the following command:
# chroot /mnt
To complete our goal, perform these steps:
Copy the GENERIC kernel to the /boot/kernel directory:
# cp -Rp /boot/GENERIC/* /boot/kernel
Create the /etc/rc.conf, /etc/resolv.conf and /etc/fstab files. Do not forget to properly set the network information and to enable sshd in the /etc/rc.conf file. The contents of the /etc/fstab file will be similar to the following:
# Device Mountpoint FStype Options Dump Pass# /dev/mirror/swap none swap sw 0 0 /dev/mirror/root / ufs rw 1 1 /dev/mirror/usr /usr ufs rw 2 2 /dev/mirror/var /var ufs rw 2 2 /dev/cd0 /cdrom cd9660 ro,noauto 0 0
Create the /boot/loader.conf file, with the following contents:
geom_mirror_load="YES" zfs_load="YES"
Perform the following command, which will make ZFS available on the next boot:
# echo 'zfs_enable="YES"' >> /etc/rc.conf
Add additional users to the system using the adduser(8) tool. Do not forget to add a user to the wheel group so you may obtain root access after the reboot.
Double-check all your settings.
The system should now be ready for the next boot. Use the reboot(8) command to reboot your system.
This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.
For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.