Home arrow Guides arrow Installing FreeBSD from Rescue (variant 1)
Installing FreeBSD from Rescue (variant 1) PDF
Thursday, 26 August 2010

This tutorial shows installation steps of FreeBSD from rescue image, booted from network (Tested on FreeBSD 8.1).

Step 1. We Configure Soft Raid First, Using Gmirror

First we create raid matrix:

gmirror label -vb round-robin gm0 ad4

Metadata value stored on ad4.

Then we add a second drive to the raid matrix:
gmirror load
gmirror insert gm0 ad6


Step 2. We create slice and partitions on RAID matrix

Before issuing fdisk on a gmirror device we must first make sure we have the following modules loaded:
geom_mirror and geom_mbr.

kldload geom_mirror
kldload geom_mbr

If on our FreeBSD rescue we do not have geom_mbr, we can copy it from an installed FreeBSD:

If you already have geom_mbr, skip following commands:

fetch http://www.freebsdonline.com/downloads/geom_mbr.ko

cp geom_mbr.ko /boot/modules

(or /boot/kernel, depending where your FreeBSD kernel modules are located)
Then load needed modules:
kldload geom_mirror
kldload geom_mbr

Now we are ready to create slice and initialize boot section of our mirror RAID matrix:

fdisk -BI /dev/mirror/gm0

It is ok to ignore the message:
fdisk: Geom not found: "mirror/gm0"

Next we will create partitions on first slice from our matrix:

bsdlabel -wB /dev/mirror/gm0s1

We will change default editor from vi to edit, for a faster edit:
export EDITOR=/usr/bin/ee
echo $EDITOR                       # to check the change

If you are using csh use instead:
setenv EDITOR /usr/bin/ee

We will enter an editor and manualy create partitions:
bsdlabel -e /dev/mirror/gm0s1

The partition table from editor will look like this:
# /dev/mirror/gm0s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:        2G       16    4.2BSD        0     0
  b:        4G        *      swap        0     0
  c:         *        0    unused        0     0         # "raw" part, don't edit
  d:        5G        *    4.2BSD        0     0
  e:      100G        *    4.2BSD        0     0
  f:        *         *    4.2BSD        0     0

We will get the following partitions:
/dev/mirror/gm0s1a    /                          - 2GB root partition
/dev/mirror/gm0s1b   swap                    - 4 GB swap partition
/dev/mirror/gm0s1c   raw, we don't edit it
/dev/mirror/gm0s1d   /tmp                     - 5G tmp partition
/dev/mirror/gm0s1e   /var                      - 100G var partition
/dev/mirror/gm0s1f   /usr                      - rest of the disk is used for usr

Now we will format all created partitions:

newfs /dev/mirror/gm0s1a
newfs /dev/mirror/gm0s1d
newfs /dev/mirror/gm0s1e
newfs /dev/mirror/gm0s1f

Step3. We will prepare (mount) partitions for installation

mount /dev/mirror/gm0s1a /mnt
mkdir /mnt/tmp /mnt/var /mnt/usr
mount /dev/mirror/gm0s1d /mnt/tmp
mount /dev/mirror/gm0s1e /mnt/var
mount /dev/mirror/gm0s1f /mnt/usr

Step 4. We run sysinstall and we install FreeBSD on hard drive mounted in /mnt


We will choose custom install and we will choose install root in /mnt.

We make sure release name is 8.1-RELEASE. We can change that from Options, in Custom section.
We configure Install Root option as /mnt instead of /.

We then choose media type either FTP or NFS, and install FreeBSD.

We choose Developer as installation type and we choose ports collection too.

Step 5. We configure FreeBSD manualy

First we configure FreeBSD network
We edit /etc/rc.conf

edit /etc/rc.conf

# -------- /etc/rc.conf ---------
ifconfig_em0="inet  netmask"

Then we edit /etc/resolv.conf

edit /etc/resolv.conf

# ------- /etc/resolv.conf

Then we edit /etc/fstab
If we used mirror we will have the following fstab:

edit /etc/fstab

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/mirror/gm0s1b             none            swap    sw              0       0
/dev/mirror/gm0s1a             /               ufs     rw              1       1
/dev/mirror/gm0s1d             /tmp            ufs     rw              2       2
/dev/mirror/gm0s1f             /usr            ufs     rw              2       2
/dev/mirror/gm0s1e             /var            ufs     rw              2       2

If we choosed not to install geom mirrored raid matrix we will have (asuming your drive is ad4):

# -------------- /etc/fstab file ----------------
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad4s1b             none            swap    sw              0       0
/dev/ad4s1a             /               ufs     rw              1       1
/dev/ad4s1d             /tmp            ufs     rw              2       2
/dev/ad4s1f             /usr            ufs     rw              2       2
/dev/ad4s1e             /var            ufs     rw              2       2

We must also modify /boot/loader.conf to load geom modules

edit /boot/loader.conf

# ---------- /boot/loader.conf -------------

If we install using custom mode we might need to put a kernel and modules after installation in our /mnt/boot directory. We can use a kernel and modules from a previous installed FreeBSD.b

mkdir /mnt/boot/kernel
cd /mnt/boot/kernel

fetch http://www.freebsdonline.com/downloads/kernel
fetch http://www.freebsdonline.com/downloads/modules.tgz
tar -xvzf modules.tgz

Now we will add a user and setup a password for that user, same for root user. User will be added to configs from /mnt/etc, which is the machine we are installing.

Important! When creating users on a memory mounted image be careful not to fill up your rescue freebsd memory partition for /, because you will not be able to create more users, you will get an error, user will be added to /etc/passwd and /etc/master.passwd but database for password authentication will not be created.

We create a user and setup a password for that user in our memory rescue freebsd (user must be invited or belong to group wheel, you will need that later to be able to su from that user to root):

adduser                    # we will add user john, in group wheel
passwd john
passwd root

After we've added a user and we change the password for that user and for root, we will copy /etc/passwd and /etc/master.passwd to our installation and then we will create database for master.passwd with pwd_mkdb.

cp /etc/master.passwd /mnt/etc/master.passwd
/usr/sbin/pwd_mkdb -d /mnt/etc/ /mnt/etc/master.passwd

You might also want to check /etc/master.passwd so you will have the proper shell for root (/bin/csh).

Reboot your computer and you will have a minimal installed FreeBSD

Step 6 We cvsup for latest sources and we rebuild kernel and world
fetch http://www.freebsdonline.com/scripts/cvsup_server.sh

For this particular server we only want to sync from cvsup kernel and world sources. We will keep default ports. Keeping or syncing ports depends on your needs, if we already have some packages built custom for our servers then we will not sync ports. This is up to your needs.

So we edit cvsup_server.sh and  and we comment line that sync ports, at cvsup-supfile generation part:

edit cvsup_server.sh

and comment this line: echo "ports-all tag=."

Then we run cvsup_server script that cvsup kernel and world, build kernel and world.

chmod u+x cvsup_server.sh

After the script finish the task you will be prompted to manualy reboot the server and go to /usr/src and install world.
So after the script finishes we will run:

cd /usr/src
make installworld

That's it.

Last Updated ( Saturday, 04 February 2012 )
< Prev   Next >

Other BSD Systems





Best BSD firewall?