Sunday, February 24, 2008

First customizations

OK, first things first. For an 'experiment' with FreeBSD I first needed it installed somewhere... for the purpose of my own mental and psychical health, I choose to get FreeBSD running in a virtual machine first.

Since I'm not eager to see it (...yet) as a viable fully fledged desktop system, I was not interested in the X part of this install so I chose a minimal install, by using the "boot only" CD.

As the time of this post, I chose the latest stable release for my i386 architecture, namely the iso I got is 6.3-RELEASE-i386-bootonly.iso. It can be found on any FreeBSD mirror. For a list of available FreeBSD mirrors, check here.

Alright, I got the iso... then what? I needed a virtualisation environment... so after thinking about the bad things I've heard about QEMU and Xen I decided to go for one of the other two decent alternatives - VMware Server and VirtualBox.

I used to use (!) VMware Server before, but I had a few hops with it. First of all, when I first found out about it and decided to give it a go, I had to download it like any foolish mortal would from VMware's website - it was a pretty big tar.gz, a little over 100 MB -, then unpack it and then run vmware-config.pl - their, uhm, "install" script. I always had troubles recompiling the vmmon module after a kernel update, and I also did a lot of system re-installs back then (you know, the old story, small hard disk with lots of partitions... that from time to time needed resizing and stuff). I always forgot to apply the damned vmware-whatever-patch-any-any-update patch (or something like this, anyway) so, being sick of all this stuff, decided to try something a little bit more lightweight and friendly, such as VirtualBox. Sure, VirtualBox was smooth and all... until I noticed some disadvantages. Here are two of them: if I ran some Linux distro inside a virtual machine in VirtualBox, I wasn't able to ssh to it from my own host OS "out-of-the-box" (of course it's possible, but you have to set up bridged networking and I just didn't have the mood then to do it) and the second issue is that... well, VirtualBox can't boot FreeBSD 6.3-RELEASE. (The reason I don't want to use 6.2-RELEASE in VirtualBox is the fact that I can't get on a local FTP mirror the files for the 6.2 release, they only have the stuff for 6.3, so, since I don't want to use the 'multipurpose' FreeBSD FTPs - I need to speed things up, dammit! - it's just gonna have to wait).

Long story short, when I eventually got back to VMware, poof! the magic had happened, I found it in the Ubuntu repos. (Yeah, I currently run Kubuntu 7.10.) So after a smooth vmware-server install it just... "works". NAT networking out of the box and stuff. No more headaches.

Alright, so much for the intro. So I finally had a minimal FreeBSD 6.3 install in a VMware virtual machine. Some of the first customizations:
  • make sure SSH (and root login) is enabled in the FreeBSD virtual machine:
vi /etc/ssh/sshd_config
Find the line
# PermitRootLogin no
and change it into
PermitRootLogin yes

vi /etc/rc.conf
Add the line
sshd_enable="YES"

Finally,
/etc/rc.d/sshd restart
  • provide myself with a friendly login:
vi /etc/rc.conf
Find the line
hostname="whatever"
and change it into
hostname="dvorak" # it's obviously just an example...

Then in the guest OS, look in ifconfig's output for a line looking like this one:
inet 192.168.40.129 netmask 0xffffff00 broadcast 192.168.40.255

OK, now I know the guest's address, i.e. 192.168.40.129. In the host OS, edit the /etc/hosts file in order to add the guest's ' ' set:
vi /etc/hosts
Under the line
127.0.0.1 localhost
add a new one:
192.168.40.129 dvorak

Perfect! Now I can simply
ssh root@dvorak
anytime I need
  • next, I'll want to get bash and add some color to the directory listings...
pkg_add -rv bash
Next, get the $SHELL to default to bash:
chsh -s /usr/local/bin/bash

vi ~/.bash_profile
Add the following lines:
# First, define some useful aliases:
alias ll='ls -l'
alias lh='ls -lh'
alias lA='ls -la'
# Add some color:
CLICOLOR="YES"
export CLICOLOR
LSCOLORS="ExGxFxdxCxDxDxhbadExEx"
export LSCOLORS

Notice how FreeBSD differs in this point from Linux, where:
- I only need ~/.bash_profile to contain... stuff;
- Apart from LSCOLORS, I also need to set CLICOLOR to YES and export it as well.

More info on LSCOLORS in a future post.
  • next I'll need to get some stuff on my system since, well, at install time I only chose "Minimal" install:
Run (as root)
sysinstall
and from sysinstall's main menu -> Configure -> Distributions -> [ x ] base ; [ x ] man ; [ x ] ports for a start; it's obviously a good idea to select from here [ ] src and, from it, [ x ] base and [ x ] sys - one can never know when kernel recompiling is needed.
  • OK, suppose that at the previous step I didn't use sysinstall to install the ports collection as well. There is another method to get the ports collection. For this example, I'll use cvsup.
pkg_add -rv cvsup-without-gui

Now, we need to edit the ports-supfile file... first, make a copy of it (and work on the copy):

cp /usr/share/examples/cvsup/ports-supfile /root
vi /root/ports-supfile


Find the line
*default host=CHANGE_THIS.FreeBSD.org
and change it such that it will point to a cvsup mirror near you:
*default host=cvsup1.ro.FreeBSD.org

Next you need to make up your mind - you either get all the ports - in this case save the file and exit - either you want to get just a part of them; if so, find the line
ports-all
and comment it out:
# ports-all
and look below to the list of all the ports that make up ports-all; remove the comment '#' sign if front of the ports you do want to get (and leave the comment '#' sign if front of the ports you don't want), but you need to make sure you enable (i.e. remove '#' in front of) ports-base!

Next, you need to run (
-L refers to the level of verbosity, and 2 means 'high'):
cvsup -L 2 /root/ports-supfile
And now go get a cup of tea or something...
More on ports in the FreeBSD handbook.

0 comments:

Post a Comment