Wednesday, June 24, 2009

My First FreeBSD Fling

Hello FreeBSD

The elusive *nix. Nobody knows about it yet it is one of the most widely used server operating systems. The wikipedia entry mentions it as the unknown giant of the internet. Huge internet portals like Yahoo! run on it. Why is it that no one knows about this widely used OS?

Please remember that I am no *nix guru. I have used a lot of Linux distributions (mostly Debian based) in the past two and a half years. I don't know anything about programming but I don't mind messing around at the command line. In fact I am a medical student whose main hobby is Linux. Weird but true.

I have tried at least three times before to get FreeBSD installed on my laptop (a three year old Think Pad R60) but failed spectacularly all three times. I didn't like the ncurses like installation interface nor did I like the unfriendly options I had to select through. But this time I did it. OK, it's in a Virtual Box environment but still, come on, I've got a working FreeBSD 7.2 install.

All you need is lots of patience. First of all you need to read through the documentation available here : http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/install.html

It's given very systematically. You can use it as you go through the installation process step by step.

I downloaded the three CDs instead of the DVD. This is because the download server didn't support resuming and my internet connection is not very stable. So I minimized the risk of download failure and downloaded the distribution in three CDs. You only need the first CD to have a FreeBSD install. But in order to have a graphical environment you need the other CDs.

Installation

I used Virtual Box 3.0.0 Beta on Linux Mint 7. I allocated around 950MB RAM and 128 MB video memory to the virtual machine and gave it an 8GB hard disk. This is more than enough as the minimum requirements for the OS are really low. I recommend at least 512MB RAM if you intend to use KDE or GNOME as your desktop environment.

I booted the first CD and the program called sysinstall started automatically. I am not going to waste time and space by going through the installation screen shot by screen shot like most of those Ubuntu worshiping sites. The installation procedure is given in detail in the official documentation. Screen shots are provided for each and every step. And PLEASE FOLLOW THE DOCUMENTATION FOR EVERY STEP. I skipped some steps during my previous attempts and ended up with handicapped installs. Curiosity kills the cat. But curiosity is also the fuel of science.

I assigned the whole disk for the OS. I selected to install GNOME packages so the second and third CDs were required. I forgot to select Firefox from the package list. Anyway I learned how to use the Ports installation method by compiling Firefox.

After the install I booted into the OS and I was asked to enter the user name and password to login. After that I got a welcome note from the FreeBSD team but no graphical environment. So I typed in startx and something like the default x login screen came out but everything froze. I had to do a hard reboot. I expected to see the GNOME login screen after typing startx but it never showed up. I googled a bit and came upon this :

In order to make the most of your new GNOME Desktop, you will want to start all of the GNOME-related services at boot-time. If you wish to take full advantage of GNOME, add the following to /etc/rc.conf:

gnome_enable="YES"

So I decided to edit the file from the console and typed nano /etc/rc.conf

I always found nano installed in almost every Linux distribution but it wasn't there in this *nix system. I googled again and the FreeBSD site directed me to use ee. Yup, the editor's called ee. So I entered this:

#ee /etc/rc.conf

ee has a very user friendly interface. Just scroll to the bottom of the file, add the required lines and hit Esc. Then select save and save it. You need to be a root user to do this. If you are not, then type:

$su

Enter the root password and then open up the rc.conf file with ee.

It is not recommended to use the root account on *nix systems unless you know what you are doing. The su command gives temporary root powers to the user.

After you have edited the file type : startx

The GNOME login screen will appear and you will be able to login to your FreeBSD installation.

Installing Software

There are two ways to install software on FreeBSD system. One is to use pre-compiled binary packages and the other is to compile it from source using the ports system. I chose to use the latter as the former is no different from apt-getting packages. It might not be the same as apt but ports is more different from apt than pkg_add is. I like learning new things.

You should have selected the to install the Ports tree during the install. You can do it later also by bringing up the sysinstall tool.

Basically you have the whole application list arranged in categories in the /usr/ports folder. Categories like editors, www, net etc. can be found. This is just like the way most graphical package mangers arrange available software in to categories. The only difference is that here it is arranged as folders. So you can use your file browser to go through the huge lists.

When you enter a category you find the folders for the available software. Enter those folders and you will find a folder containing the sources and some installation scripts.

Forget all that. Let's move on to the part where you get software installed.

Fire up the terminal in GNOME, and type su and enter the password to become root. Then cd to /usr/ports

#cd /usr/ports

I'm assuming you have got your network up and running as you had configured it during the install.

Say you wanted to install htop, an interactive process viewer.

Perform a search using this syntax

make search name=''name of the application without the quotes''

I searched for htop and the path to the ports directory for htop was displayed.

cd to the directory. In this case /usr/ports/sysutils/htop

After this you are supposed to type 'make', then after the process has finished, 'make install' and then later 'clean' to clear out the temporary files. You can combine this into 'make install clean'

So type:

#make install clean

As soon as you type this the program checks for the source code and if it is not available it downloads it from the server. After that the configuration starts. If all the dependencies are not met even they will all be downloaded, configured, compiled and installed. Yay! No dependency hell here.


After the initial configuration the program compilation starts and then the installation. Some compiling time options might appear depending on the program. Select what is appropriate.


Compiling will take time depending on the size of the source code. Firefox took over 30min for me while htop took less than half that time. Don't try compiling OpenOffice or KDE, it's better to install these from the pre-compiled binaries or else you'll be staring at the compiling screen for hours.


After the install is done you will find your program in the GNOME menu.


The first program I compiled was Firefox 3, even before htop.

Compiling from source has never been more easier.

Conclusion

I like FreeBSD now. I have fell in love with Ports. Compiling from source has its own advantages as you can specify several compile time options and the compiled program is better optimized for your particular system. And it feels so damn geeky! I love it.

I've been running FreeBSD for more than 10 hrs now and I haven't had a single crash other than the initial trouble with getting GNOME to work.

There are several features in FreeBSD which make it a server guy's best friend (like jails and stuff) but this is just the beginning for me. I hope I learn more about this great operating system which has stood the test of time and M$.

I'm looking forward to a great experience from FreeBSD. Kudos to the FreeBSD team for creating Ports. :)

7 comments:

  1. FreeBSD is great but there are a few FreeBSD based BSD's that are built soley for new users and help with the pains you outlined in your article.

    Check out these two for example:

    PC BSD (http://www.pcbsd.org)
    DesktopBSD (http://www.desktopbsd.net)

    ReplyDelete
  2. @ddreggors :I have tried PC BSD three or four times and I really liked it. I'll see if i can write a review of their latest release with KDE 4.
    I never tried DesktopBSD. I'll check it out soon.
    @Chewy : Yes it is!!

    ReplyDelete
  3. *BSDs are way more stable than linux, plus they were the first to do networking properly, rumours are out there that the windows IP stack was borrowed from BSD, don't know if thats true or not.
    There are some other forms of BSD that are pretty sweet too. OpenBSD is designed to be the most secure default install available, it was originally funded by DARPA. FreeBSD is sort of a catchall/Desktop. NETBSD is designed run on anything. And I'm not sure what DragonFlyBSD is for.
    Anyways, kudos on a successful install :) BSD is pretty sweet.

    ReplyDelete
  4. A common error:
    When you execute "su", you are logging to root BUT with all environmental variables of your "normal" user.
    The correct manner is make "su -" instead "su" only. With the "-" you are logging in the root account WITH all root environmental varibles.

    Have a nice day ;-)
    TooManySecrets

    ReplyDelete
  5. @TooManySecrets: Thanks a lot for making that clear
    @Xonogenic: I've come across a how to on installing NetBSD on a toaster...

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete