Installing FreeBSD 6.1

From DFWLPiki
Jump to: navigation, search

Advise to Check a Different Document

At this time, FreeBSD 6.1 is still supported for security updates, but FreeBSD 6.2 has a much better driver set, and works better on more machines. I encourage you to download a 6.2 install .iso, and check out my newer document Installing FreeBSD 6.2.

Scope of This Document

This article is to guide you thru the installation and system preparation for FreeBSD 6.1. This article is not intended to produce a working system, but is the foundation for the progression to either a desktop system or a server. Once this document has been followed to completion, you may either choose to follow the Server or Workstation documents for your system deployment.

Also, I would like to note that the FreeBSD Handbook is probably the most valuable resource you will ever find for technical details of FreeBSD.

FreeBSD Installation

As you can see, the first portion of the guide has many screen shots, which I hope will help you to get thru installation successfully. FreeBSD installation is actually quite simple, and after you have done it a few times, it will be second nature. For this installation, you will only need CD1. Insert the CD, and boot your system.

First up, is Country Selection. Select your country and hit enter.

On the Main Menu, we will use the standard installation.

Partition creation with fdisk (these are also known as 'slices') - Hit OK to proceed. The first step is to select the drive(s) that will be used for our installation. For this demonstration, I have 2 disks in the machine that will be used. Use the up/down arrow keys to select your boot drive, and hit the space bar, and you will proceed to the Partition Editor screen. I always hit 'A' to use entire disk, then 'S' to toggle the boot flag, then 'Q' to quit. I've done it many times, so i just hit 'ASQ' in quick succession. Hitting 'Q' takes you back to the bootmanager screen. Select to use 'BootMgr', and you will be returned to the disk selection screen. If you have a second drive to configure partitions for, arrow down and hit space. For this second drive, the only difference is we will not hit 'S', as we do not want a boot flag on this drive. For my second disk, I just hit 'AQ' in succession.

Now its time to create the partitions within the slices. The up/down arrows will select the different disks if you have more than one. I always use the default size that the installer picks. For disk ad0, we just hit 'A' for Auto Defaults. For disk ad2, we arrow down, and then hit 'C' for create. Hit enter for the default value for partition size, enter for the default option of FS (file system), and finally give it a mount point. I always mount my file storage at /opt. Hit Enter again, and it will show all the partitions that are about to be created when we move on.

Next, we choose our distribution. I always use the minimal install. Minimal install takes the least amount of time, and guarantees that only the most necessary items will be installed. Everything else we will need, we will compile from the ports collection. Arrow all the way down to Minimal, and hit enter. Hit enter again to take the default option to load from CDROM, and once more again to confirm 'YES' to proceed. You will see the installer build the file systems, copy the base installation over, and end with a congratulations screen. Click ok to continue on.

Ethernet configuration is pretty simple, and you begin by clicking yes or no. If you click yes, you will proceed to interface selection. Usually, your ethernet card will be listed at the top. In the example, my ethernet card is known as de0. Hit ok to continue, and you will be asked if you want to use DHCP or not. If you choose yes, ethernet configuration will end and you will be moved to the next section, if you choose no, you will be presented the Network Configuration dialog. Input your computers name, the domain name, router, dns server, and ip address/netmask, and tab down to ok. When you click enter, you will be asked if you want to bring the interface up right now. I always click yes.

Next comes a series of yes/no questions, which can be kind of confusing the first time around. Since each screen will cover a new topic, I'll number them out:
1) Do you want the machine to be a network gateway? no.

2) Do you want to configure inetd and network services? no.

3) Would you like ssh login? yes (this is not the default... change it to yes!)

4) Do you want anonymous FTP on this machine? no.

5) Configure this machine as NFS server? no.

6) configure this machine as NFS client? no.

7) Customize the console settings? no.

8) Set the machines time now? yes.

9) Is machines CMOS set to UTC? no.

Time zone selection should be straight and simple. Pick your region, and hit enter. Pick your country, and hit enter again. Finally, pick your zone and hit enter.

A few more yes/no's now: 10) Enable Linux binary support? no (if your configuration needs this later, this will be automatically added, so leave it off for now).

11) PS2, Serial or bus mouse? If you have USB mouse, then no, if you do have any of those, click yes. If yes, the next screen will allow you to test the settings, but even when I install on a PS2 mouse system, I tend to skip. Click to test if you like.

This next one is important. The packages system are applications that are all pre-compiled and ready to run on freebsd, but sometimes they can be out of date, and sometimes worse, they can be compiled to want old versions of things, such as apache. I always say no to this one, and later during Desktop or Server configuration, you will see why. so:
12) Browse the packages collection? no.

Another important one is adding the user accounts. I always choose not to add any, as during a process that is comming up here real soon, sometimes users group membership can become confused, and some people can be removed from groups they need to be in. They will be added long before the system becomes useable, so:
13) Would you like to add user accounts? no.

When you hit enter for "no to users", the next screen is to set the system managers password. This is for the root account. Hit enter to set the password now.

After the root password is set, the next screen asks "visit the general configuration" one more time?

Nope, were done. Hitting enter goes back to the Main Menu, use the arrow keys to move to Exit Install,

and hit enter. Remove the CD, hit enter, and reboot the computer. Installation is now complete.

Rebuild the World, and Recompile the Kernel

In FreeBSD, the process of recompiling the the base system, is known as "rebuilding the world". Recompiling a new kernel is also part of this process. To begin with, we need to bring down the latest snapshot of the Ports Collection. The ports collection houses a staggering amount of software that is ready to compile into FreeBSD. This process will take a few minutes.

# mkdir /usr/ports; portsnap fetch extract

First up, we need to compile the cvsup tools. I also take this time to install 'screen', since I tend to background processes while working on the console. Screen is a very useful tool.

# cd /usr/ports/sysutils/screen; make install clean

I generally prefer to add all software to my systems using only ports, however, there is a very short list of applications that i will pull down using the packages system. Packages that have dependencies, I almost strictly use ports (unless I know a package has a very safe or short list of dependencies... long story.) In this case, to save time, I've started installing the cvsup tools via packages, like this:

# pkg_add -r cvsup-without-gui
# pkg_add -r fastest_cvsup

If you want to install these items via ports, the way would be like this (but as I mentioned, you can use the pkg_add method for these 2 applications without fear)

# cd /usr/ports/net/cvsup-without-gui; make install clean
# cd /usr/ports/sysutils/fastest_cvsup; make install clean

Now, we copy the stable-supfile to /root. This file directs cvsup as to what will be downloaded. This file will cause us to follow the STABLE tree, and download all bugfixes, security updates and improvements that have been merged into the tree since the release of 6.1. Editing the file can allow you to be quite granular as to what parts of the source tree will be downloaded or updated, and no edits = full sources. I do full sources. I recently wrote a short article about how the tags work in the supfile here.

# cp /usr/share/examples/cvsup/stable-supfile /root

Update you're source tree with this command. This process can also be expected to take a few minutes.

# rehash
# cvsup -L 2 -h `(fastest_cvsup -q -c us )` /root/stable-supfile

Now that all that is completed, we move on to preparing to recompile the kernel. To do so, we need to edit the kernel configuration file. Change to the kernel source directory now.

# cd /usr/src/sys/i386/conf/

Copy the GENERIC file to a new one. Its common to use ALL CAPS of the same name as the local system. My file is called ZEUS.


Now, we need to edit a few items in the config file. First change the 'ident' from GENERIC to ZEUS (the name of your system). I use large fat32 USB drives, so I change 'options MSDOSFS' to 'options MSDOSFS_LARGE'. If you have an SMP machine, you need to add a line for 'options SMP'. After that is complete, save the file and change to the main sources directory, and lets start the rebuild of the world. For reference, were going to follow the method laid out in the FreeBSD Handbook.

First, we build the world, then the kernel. Where you see 'ZEUS' in the example below, substitute in the name of your kernel configuration file. if the 'KERNCONF=[NAME]' directive is omitted, then buildkernel will use the GENERIC config file.

# cd /usr/src/
# make buildworld
# make buildkernel KERNCONF=ZEUS; make installkernel KERNCONF=ZEUS

Now, we will reboot into single user mode for this next part. Be sure to hit option 4 at the FreeBSD boot screen. Once were at the single user mode promt, mount the system's volumes.

# reboot
# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a

Next, we run a mergemaster, and then we install world, followed by a second run of mergemaster. On the initial 'mergemater -p', there will not be many configuration files to pay attention to, but any that pop up, should be looked at closely (often, /etc/groups is one, and if you have already set up users who are members of special groups, then I would recommend having a backup of your groups file before replacingn it). Also, doing this entire buildworld process early in our servers configuration, means that almost no configuration files are in danger of being overwritten with ones that will change the way our daemons run. It is very important, that during the mergemaster operations, to look and see what files it is trying to work with. The mergemaster process is how configuration files from newly compiled versions get merged into, deleted (not used), or overwrite existing versions. For a system this new, about the only file I delete is the /etc/hosts. All the rest of them, I just hit 'I' to install and use the new version. IMPORTANT!! - If you already created some users (and thus, their groups), then the file /etc/groups is at risk of being overwritten with a clean version. To be absolutly safe, make a backup copy of the entire /etc directory, and if you accidently overwrite your groups or any other important files, you can go back and see what they originals looked like from your /etc backup folder. The missing groups can be manually written back in, or copied/pasted, etc.

# cd /usr/src 
# mergemaster -p
# make installworld
# mergemaster
# reboot

Finish by cleaning the sources, so that some things can be recompiled.

# cd /usr/src; make clean

Now, its time to add a few useful things. We will use the 'pkg_add -r' command to pull down the package versions, already compiled.

# pkg_add -r bash; pkg_add -r ncftp; pkg_add -r wget; pkg_add -r pine

Now we add our main user account, which I make a member of the 'wheel' group, so they can become root. Don’t forget, that the default configuration in FreeBSD, root cannot ssh into the server, only a user can (which is why we want a user in the wheel group, so they can become root and complete the bulk of this install via remote).

# adduser [yourname]

Deployment Direction

Now, you must decide which direction you would like to go to complete your FreeBSD deployment. Just like the old "choose your own adventure" stories from the 80s...
Do you want to deploy a server? Or do you want to deploy a workstation?