Installing FreeBSD 6.2
Scope of this Document
This article will guide you through the installation and system preparation for FreeBSD 6.2. 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.
As you can see, the first portion of the guide has many screen shots, which I hope will help you to get through 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 only one disk 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 a second drive, the only difference is you would not hit 'S', as you would not want a boot flag on this drive. For a second disk, you would 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.
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 lnc0. 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 (just the shortname), 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 timezone 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 coming 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 usable, 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 freebsd62-install.,
and hit enter. Remove the CD, hit enter, and reboot the computer. FreeBSD 6.2 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. Before we begin, lets first pull down a couple of items we will need:
# pkg_add -r bash; pkg_add -r nano
Once those are done, I prefer to set my shell permenantly to bash; then I copy the supfile we will need to /root.
# chsh -s bash; rehash; bash # cp /usr/share/examples/cvsup/standard-supfile /root # cp /usr/share/examples/cvsup/ports-supfile /root
These files direct csup as to what will be downloaded. The standard-supfile will cause us to follow the RELENG tree, and download all bugfixes and security updates 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. There is actually one line in this config file that tells csup what sources to pull down. It is this line (I use the editor nano, which we pulled down just a moment ago):
*default release=cvs tag=RELENG_6_2
- Note that the above line only is in the standard-supfile, and the ports-supfile has a different '*default release' line (which should NOT be changed).
If you change that line to just RELENG_6, it would pull down 6-STABLE, which is also fully up to date with all security and bug fixes, but also may include code merged in from 7.0-HEAD. The downside to using STABLE, is that your kernel is not named after the security patch your system is runing, and me personally, I easily forget when my last kernel compile was. For this reason, I stick to RELENG. Right before 6.2 came out, my kernels were named 6.2-RELEASE-p2 (2nd security patch for 6.2). There is also another line that must be changed in (both) supfiles, and it is:
There are cvs servers located all around, the one that works best for me is cvsup5. I edit my line to read:
Update your source tree with this command. This process can also be expected to take a few minutes.
# csup -g -L 2 /root/standard-supfile
Right now would also be a good time to pull down the current snapshot of the ports tree:
# csup -g -L 2 /root/ports-supfile
Note, that later when you are ready to update your ports or source trees, that the exact same commands as above will be re-used. 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 ATHENA.
# cp GENERIC ATHENA
Now, we need to edit a few items in the config file. First change the 'ident' from GENERIC to ATHENA (the name of your system), as well as remove the lines for 'i486' and 'i586'. 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 'ATHENA' 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=ATHENA; make installkernel KERNCONF=ATHENA
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 'mergemaster -p', there will not be many configuration files to pay attention to, but any that pop up, should be looked at closely. However, 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
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 ncftp; pkg_add -r wget
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]