Friday, October 3, 2014

Stepping into freeBSD

Intro

FreeBSD unlike Linux is a pure UNIX OS(I really don't see the difference, that's just me). Any how this writing is to specify the stuff I did to get FreeBSD up and running on my Dell Inspiron 630m. 

The machine has a centrino processor and has only 512 MB of RAM, so my choice of software has to be lightweight and specific. For these reasons compiling from ports seem to be the best option. Using the handbook, I was able to get i386 version of FreeBSD(usb image) installed on the machine.  Inorder to make a bootable usb stick with windows I used this.

Basic stuff 

User Management:


I had setup a normal user account during the initial setup. On my fresh install the first thing I do is to add my user to the wheel group. If I have to issue an "su" I need to be in the wheel group. I do that with 

pw groupmod operator -m user_name

And we are done. If we didn't create a user at the initial setup then issue the following

pw user add -n user_name -c "Full_user_name" -g wheel -m -h 0

Btw, I dont need to mention this, but the above need to be executed as root.

Lets setup the system:


I did mention that I need the system to be light on resources, so Im going to compile using ports. By doing so, I get to disable options of software that I'm not going to use. Enough chit chat, lets start.

1.Getting ports


As root

portsnap fetch extract update

I watched an entire movie while this was completing. Based on ones machine, this can take a while. But totally worth the effort.

Now I'll install a port management tool called portmaster. I do that like this

cd /usr/ports/ports-mgmt/portmaster/ && make install clean

When that completes we need to configure it a bit. So I take a sample config file provided with the port and use that. I do that like so

cp /usr/local/etc/portmaster.rc.sample /usr/local/etc/portmaster.rc

ee /usr/local/etc/portmaster.rc


ee is freebsd's default text editor. Add the following into it

# Always delete stale distfiles without prompting (-d)

ALWAYS_SCRUB_DISTFILES=dopt

# Be verbose (-v)

PM_VERBOSE=vopt

# Install packages for build-only dependencies (--packages-build)

PM_PACKAGES_BUILD=pmp_build

# Delete build-only dependencies when finished (--delete-build-only)

PM_DEL_BUILD_ONLY=pm_dbo

#Suppress the build confirmation message (--no-confirm)

PM_NO_CONFIRM=pm_no_confirm


Save and exit out from ee. Now we'll use portmaster to compile our ports.

Below are some commands I find useful.

update all ports:

   portmaster -a
   force:
      portmaster -af
  
search for updates and list all installed ports by category:
     
   portmaster -L
   portmaster -L | grep "New version available:"
     
clean stale distfiles:

   portmaster --clean-distfiles
   with out promt:
      portmaster --clean-distfiles-all
  
uninstall the port and it's dependencies:
  
   portmaster -e target_port

rebuild the specified port, and all ports that depend on it:
  
   portmaster -r target_port

2. Setting up X


portmaster x11-servers/xorg-server

portmaster x11-drivers/xorg-drivers

portmaster x11/xinit

portmaster x11/xauth

portmaster x11-fonts/xorg-fonts

portmaster x11-fonts/webfonts

 The above will install a minimal Xorg server and a couple of drivers for keyboard and mouse. Disable hal in each installation of a port. Now we configure X

Xorg -configure

cp /root/xorg.conf.new /etc/X11/xorg.conf

To configure mouse

echo "moused_port=\"/dev/psm0\"" >> /etc/rc.conf

echo "moused_enable=\"YES\"" >> /etc/rc.conf


3.Window Manager


I love #! linux and openbox, So i'll use openbox on this machine.


portmaster x11-wm/openbox

mkdir ~/.config

mkdir ~/.config/openbox

cp /usr/local/etc/xdg/openbox/menu.xml ~/.config/openbox/menu.xml

cp /usr/local/etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml

touch ~/.config/openbox/autostart.sh && chmod +x ~/.config/openbox/autostart.sh

echo "#!/bin/sh" >> ~/.config/openbox/autostart.sh

echo "exec openbox-session" >> ~/.xinitrc

I need a panel so,

portmaster deskutils/pypanel

I'll want it to autostart with openbox so,

echo "(sleep 2 && pypanel) &" >> ~/.config/openbox/autostart.sh

4.Automounting USB drives


portmaster sysutils/automount

Add automounter_enable="YES" to /etc/rc.conf and we are set.

With that my freeBSD box is setup. More writings will follow. Thank you to taz from the forums. I just took his guide and replicated it here.

~aktsbot