Search
Social Profiles
Twitter Feed
Powered by Squarespace
« Linux/BSD: Serial Console vs SSH | Main | Ubuntu 9.04 Beta »
Wednesday
Apr082009

Introduction to FreeBSD for Newbies

This makes no attempt to replace the most excellent FreeBSD Handbook and simply provides a quick overview of how things work with FreeBSD for new people.

FreeBSD Installation

Here are some of the important points to bare in mind when installing FreeBSD.

FreeBSD can run on both 32 bit and 64 bit processors. If you are unsure what version to use, the 32 bit version can run on both 64 bit and 32 bit processors however the 64 bit version can only run on 64 bit processors. I would recommend people to read more about the x86 and x86-64 architectures if they are unsure. Other processors architectures like PowerPC and Sparc64 are supported by FreeBSD but most people are not likely come across these without knowing what they are.

Hardware requirements are expected to be at least in this general area, FreeBSD can be run on lower spec hardware but roles are limited.

  • Any modern processor (Pentium or better)
  • 64+ MB of RAM
  • 500+ MB of Disk space

FreeBSD has a strange partition system if you're not use to it. FreeBSD makes a single slice on the disk and makes more partitions internally, this is to get around design limitations on some hard drives. This differs from the more traditional way of installing to separate partitions that is common with Linux.

Full details on the installation of FreeBSD can be found in the install chapter of the Handbook.

Base system

FreeBSD has a base system (the kernel and all the utilities required for operation) that is developed centrally by the project and are closely integrated with each other. Third party applications (i.e. programs that are not required by everyone and not part of the base system) like web servers and desktop environments are installed via the Ports system.

Linux doesn't have a centrally developed base system as it has the kernel (the core of the Operating system) and collection of programs that are put together on top of the kernel to get it working. These programs are combined from different places unlike the FreeBSD method. The closest thing to a base system in Linux is a minimal install of programs that everyone would require.

Base system updates

One of the method of updating the base system is freebsd-update. This allows binary updates to take place without having to patch the source code and use the source to rebuild the system. The system can be configured to check every day for new updates and email the root user. Freebsd-update can also be used to update minor and major versions of FreeBSD.

If you don't trust binary updates you can apply patches to the source tree and then use that to rebuild the system. Naturally this method has a high overhead in time and resources used.

Installing Binary Packages

A good introduction into source packages vs binary packages can be found here. Installation of binary packages is very fast compared to building from source and large programs like Firefox normally only take a few minutes when installed as a binary package.

Installation of Firefox as a binary package is as simple as running this command.

# pkg_add -r firefox

Ports System
The Ports system is used in FreeBSD to install software that is not part of the base system. The Ports tree can be installed at the initial system install but you must make sure it is installed before you can install from the Ports tree. The Ports tree is a large amount of files and directories located at "/usr/ports".

There are a few ways of installing and updating the Ports tree, these are CVSup and Portsnap. I find Portsnap to be superior to CVSup as it requires no configuration, it uses a normal web connection over HTTP (that solves connection problems with firewalls) and verifies the download via an encryption key. The full details of how to use Portsnap can be found in the FreeBSD Handbook.

CVSup is much more complicated than Portsnap and I don't recommend it's use. Only one update method should be used to protect against conflicts in the tree.

Installing From Source with The Ports System
A Port is a directory containing a few files that the system needs to fetch to build the software. The Ports are sorted into categories (as shown here) that helps keep the tree organized. Before we can install the port you first must change into the port directory as shown below. In this case 'sysutils' is the category and 'lsof' is the individual port directory.

# cd /usr/ports/sysutils/lsof

Then like most other software that is installed from source, these three commands will fetch, compile, install and then delete the build files. Warning: Compiling large packages (desktop environments, Firefox, etc) can take a long time to complete.

# make
Which starts by downloading the program source code and compiles it.

# make install
This stage installs the compiled code into the system so it can be used.

# make clean
This command deletes the directory used in the build process which will save disk space.

These stages can be combined into one command to save time.

# make install clean

Ports Upgrades
There are a few ways to upgrade the installed ports on FreeBSD, these are Portupgrade, portmanager and portmaster. Only one of these needs to be used to update the installed ports and they are all installed via the Ports/Package system.

I prefer to use Portupgrade myself because it provides some tools I find useful.

Ports/Package Removal
The 'pkg_info' and 'pkg_delete' commands are used to find the full program name (including version number) and remove it from the system. This example I looked for mysql and found both server and client software, we want to remove the server.

# pkg_info |grep mysql

mysql-client-4.0.27 Multithreaded SQL database (client)

mysql-server-4.0.27 Multithreaded SQL database (server)

# pkg_delete mysql-server-4.0.27

More information can be found about the package system here.

Recommended stuff
portaudit is one thing that everyone that uses a FreeBSD system should look at.

Further Reading

FreeBSD: Resources for Newbies.

The Complete FreeBSD Book (Printed and free download).

Frequently Asked Questions for FreeBSD 6.X and 7.X

PC-BSD For people that are interested in running FreeBSD as a desktop.

The FreeBSD Diary Neat site about FreeBSD.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>