Friday, September 18, 2009

HowTo: Mount EXT2FS partitions with inode 256 on FreeBSD

Mounting ext2/ext3 slices (or "partitions" in the Linux world) is easy on FreeBSD... if the filesystem was NOT created with inode 256 that is!

If you are one of those unlucky bastards this post presents the required steps on how to patch the FreeBSD 7.2 kernel module that mounts ext2/ext3 filesystems.

First let's begin by installing the sysutils/e2fsprogs application that provides tune2fs which will allow us to confirm that the ext2/ext3 filesystem was in fact created with inode 256. Assuming that the target slice is in the /dev/ad4 disk:
  • % su
  • # cd /usr/ports/sysutils/e2fsprogs
  • # make install clean
  • # rehash
  • # fdisk /dev/ad4
******* Working on device /dev/ad4 *******
parameters extracted from in-core disklabel are:
cylinders=395136 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=395136 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 131 (0x83),(Linux native)
start 63, size 80262 (39 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 4/ head 254/ sector 63
The data for partition 2 is:
sysid 130 (0x82),(Linux swap or Solaris x86)
start 80325, size 1012095 (494 Meg), flag 0
beg: cyl 5/ head 0/ sector 1;
end: cyl 67/ head 254/ sector 63
The data for partition 3 is:
sysid 131 (0x83),(Linux native)
start 1092420, size 10008495 (4886 Meg), flag 0
beg: cyl 68/ head 0/ sector 1;
end: cyl 690/ head 254/ sector 63
The data for partition 4 is:
sysid 15 (0x0f),(Extended DOS (LBA))
start 11100915, size 350907795 (171341 Meg), flag 0
beg: cyl 691/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
  • # tune2fs -l /dev/ad4s1 | grep -i 'inode size'
fdisk is used to list the slices that exist on the disk. Sysid 131 means that a ext2/ext3 slice exists and this is target for tune2fs.

Next let's fetch the patch:
  • % wget http://pflog.net/~floyd/ext2fs.diff
In alternative, get the patch from here:
  • % wget http://pastebin.ca/raw/1280738
Now that we have the patch, let's proceed by applying it and build the patched module:
  • # cd /usr/src/sys/gnu/fs
  • # patch < /path/to/patch
  • # cd /usr/src/sys/modules/ext2fs
  • # make depend ; make obj ; make ; make ; make install ; make unload ; make load ; make clean
This way you'll build all dependencies for the module, build the module itself, install it, unload the current loaded module and finally load the new one.

Having the new module loaded you can now successfully mount your ext2/ext3 filesystem:
  • # mount -t ext2fs /dev/ad6s1 /mnt
That's it!

References:
kern/124621: [ext3] [patch] Cannot mount ext2fs partition
man mount
sysutils/e2fsprogs

Thursday, September 17, 2009

Tip: Introducing the PKGDIR environment variable on FreeBSD

Though I prefer using the ports tree to install applications on FreeBSD, the fact is that packages are way faster especially if your hardware is old or you just want to bring a test install online as fast as possible.

If you want to keep the downloaded packages, you need to set the PKGDIR environment variable pointing to the place where to store the downloaded .tbz files.

Here's how to set PKGDIR with the t/csh shell to /usr/ports/packages/All:
  • % su
  • # setenv PKGDIR /usr/ports/packages/All
  • # mkdir -p /usr/ports/packages/All
To download, store and install a package named foo:
  • # pkg_add -Kr foo
The -K switch informs pkg_add that you want to keep the downloaded package on the directory defined by PKGDIR.

Using packages is all fine and dandy, however not all applications in the ports tree are available as packages due to licensing issues.

I found out that after setting the PKGDIR, every single port that I tried to install failed with the same error: "Missing pkg-descr".

To fix the problem simply unset the PKGDIR environment variable like so:
  • # unsetenv PKGDIR
And voilá! You can now use the best of both worlds.

Tuesday, August 25, 2009

Tip: Fetch and password-protected web pages

In order to make fetch (the FreeBSD downloading tool) ask for username/password when it encounters a password-protected web page, you can set the environment variable HTTP_AUTH to 'basic:*'.

Users of t/csh shells can temporarily set the environment variable like so:
% setenv HTTP_AUTH='basic:*'
To set it permanetly we need to add it to .cshrc:
% vim ~/.cshrc
setenv HTTP_AUTH 'basic:*'
And that's it.

HowTo: Intel PRO/Wireless 3945ABG on Debian

I've recently dabbled with Debian Lenny on my Dell D620 and found myself needing to access my wireless network.

These are the required steps to activate the Intel PRO/Wireless 3945 ABG device on Debian GNU/Linux 5.0 Lenny:
  1. $ su
  2. # aptitude install firmware-iwlwifi
  3. # modprobe -r iwl3945 && modprobe iwl3945
  4. point to the Network Manager icon on Gnome's top panel and enter the details of your wireless network
Do notice that firmware-iwlwifi is a non-free firmware so you need to enable the non-free repositories. To do so point to System -> Administration -> Software Sources -> Debian Software and enable the non-free and contrib repositories.

I found the whole process of enabling and using 3945ABG on Debian very simple and straightforward which was a welcome change from the days of the old ipw driver ;)

Tip: FreshPorts search plugin for Firefox

There are several ways to find software available for FreeBSD.

The FreshPorts website tracks changes to the third party applications in the ports tree as they occur. Users of the Firefox web browser can install a search engine to be able to search through http://www.freshports.org/ and find software available for FreeBSD on a friendly manner.

To do so point to http://www.searchplugins.net/pluginlist.aspx?q=freshports&mode=title and click to install the search engine. After installing it go to Firefox's search box where Google's engine usually sits and choose the newly installed FreshPorts search engine.

By doing so you can search for applications to install on FreeBSD from the comfort of Firefox.

Sunday, August 9, 2009

Book Review: X Power Tools

Short and to the point books.

That's the trend you'll notice after reading stuff like The Book of PF, Building a Server with FreeBSD 7 and BSD Unix Toolbox. X Power Tools happily joins the mentioned groups... with distinction.

The book is divided in 15 sections which are further organized into articles going over subjects such as the history of the Xorg server, configuration (how to build a xorg.conf), advanced configuration (including multiple displays) and troubleshooting in the book's Part I.

Client oriented subjects are brought in with Part II, which covers many of the rather unknown applications that are part of Xorg, e.g. xmag, xset, xdpyinfo, xfontsel and many others.

Part III exposes the reader to color, fonts and keyboard configuration.

Using X remotely is covered to a reasonable extent in the book's Part III. Here X tunneling with SSH and VNC are discussed alongside XDMCP and xauth.

In a rather unexpected way, the author chose to wrap-up the book by going over the details of configuring X for a kiosk.

As a side note it was nice to see that the author didn't focus only on Linux but also took into account FreeBSD when writing the book (moused settings are analysed).

It should be pointed out that the book was printed in late 2007, so HAL device configuration of keyboard, mouse and displays aren't discussed. However, in my opinion anyone wanting to read this book has already dealt with the situation and is looking into expanding his knowledge of Xorg into less focused things such as fonts, raw X terminal, xinit, etc.

X Power Tools is very handy and well structured making it a good alternative to those that avoid reading Xorg's extensive man page (such as yours truly).

If the Xorg subject appeals to you buy the book. Though a bit expensive, the book is a must have if you want to dwell on Xorg from a very hands-on approach.

Wednesday, July 1, 2009

Tip: Fix portaudit database error

I use portaudit to check installed packages on my FreeBSD systems for knwon vulnerabilities. However the tool behaved quite ackwardy today.

By running:
  • # portaudit -Fda
It outputed:
auditfile.tbz 100% of 53 kB 56 kBps
portaudit: Database too old.
Old database restored.
portaudit: Download failed.
The workaround was posted on freebsd-questions mailing list and consists of editing portaudit's configuration file and changing the mirror address:
  • % su
  • # cp /usr/local/etc/portaudit.conf.sample /usr/local/etc/portaudit.conf
  • # vim /usr/local/etc/portaudit.conf
portaudit_sites="http://www.FreeBSD.org/ports/"
  • # portaudit -Fda
In a couple of days the mirror issues should be fixed so by then you can revert to the default portaudit_sites="http://portaudit.FreeBSD.org/".

For more info have a look at portaudit's man page and at http://docs.freebsd.org/cgi/getmsg.cgi?fetch=933878+0+current/freebsd-questions.

Tuesday, June 30, 2009

Tip: Scroll console output on FreeBSD

People coming from Linux will find that they can't scroll back through the console output the same way on FreeBSD.

In FreeBSD you need to press "Scroll Lock" and use the arrow keys, PageUp and PageDown to be able to scroll backwards and forwards the console output. To go back to the prompt press "Scroll Lock" again.

Wednesday, May 13, 2009

Book Review: The Best of FreeBSD Basics

Having read Lucas' Absolute FreeBSD any other BSD book I read ends up being measured against it.

The Best of FreeBSD Basics (TBFB) is essentially a compilation of Dru Lavigne's articles at O'Reilly Media and this is exactly the books weakness: there is no backbone, no underlying purpose or scope. When one picks up Absolute FreeBSD BSD that person will know that network/system administration is the book's focus, when one pick Builing a Server with FreeBSD 7 service installation and configuration is the core, with BSD Unix Toolbox the reader will acquire knowledge on tons of system configuration commands.

However with TBFB its purpose isn't discernible; sometimes it's a tip, on occasion a tutorial, at times advices, all in a very disconnected way between each other. Also, sometimes during the book you'll come across stuff that is just duplicated from a previous section/chapter which is just wrong.

The book does have its shinning stops. It brinks with Dru's love for the operating system by presenting small details that you won't find in any other BSD book. In this perspective the book is an adventure through the wonderful world of FreeBSD much like a blog dealing with one's notes of his adventure in exploring a new OS (like my own blog for instances).

Noticeable is the fact that some of the articles were "updated from FreeBSD 4 and 5 to reflect the usage on FreeBSD 6 and 7" as the book's back states. And that just comes back to haunt you, namely when csup and supfile usage is discussed in a way that's just outdated for FreeBSD 7.

Now... do I recommend it? First get Absolute FreeBSD. Next if you are into system administration get BSD Unix Toolbox and get yourself Building a Server with FreeBSD 7 if you are planning on building a personal server. After you've gone through these dive ahead and get The Best of FreeBSD Basics.

As an end note, I'd really like to see a BSD book by Dru written from scratch maybe even focusing on the BSD certification initiative. Now that would be pure gold ;)

Monday, May 4, 2009

HowTo: Enemy Territory on FreeBSD

Update 26/03/2012:
With the introduction of Fedora 10 Linux compatibility environment, step 3 isn't required.
Update 10/05/2012:
Ever since EvenBalance stopped supporting Enemy Territory step 5 should be ignored. Please refer to HowTo: Get etkey and Punbuster files on Enemy Territory. If time permits I'll create a new post on how to install Enemy Territory for FreeBSD 9, until then ignore steps 3 and 5.

Wolfenstein: Enemy Territory is a free multiplayer FPS that takes place in the World World II pitting two teams (Allies and Axis) against each other for victory.

The game was originally going to be a retail expansion pack for Return To Castle Wolfenstein but the project was cancelled, Activision however decided to release it during 2003 for free.

In this post I'll detail the steps required to install and update Enemy Territory, the ET Pro mod, PunkBuster and XQF on FreeBSD.

1) Install and update Enemy Territory

Become the superuser:
% su
And install the required port:
# cd /usr/ports/games/linux-enemyterritory
# make install clean
This will pull Enemy Territory's installer from the web. If any port options pop up stick with the defaults and choose OK to continue.

If you don't have the Linux Compatibility Environment proceed to step 2, otherwise jump to step 3.

2) Enable the Linux Compatibility Environment

Enemy Territory needs both FreeBSD's Linux kernel module and near-minimal installation of a Linux distribution. By default, FreeBSD 7.x uses Fedora Core Linux 4.

The linux-enemyterritory port pulls in linux_base-fc4 so we just need to load the Linux kernel module at boot time. To do so run:
# echo 'linux_enable="YES"' >> /etc/rc.conf
3) Install Linux X.Org libraries

Wolfentein: Enemy Territory requires Linux X.Org libraries to load properly. To install them run the following command:
# cd /usr/ports/x11/linux-xorg-libs
# make install clean
4) Install the ET Pro mod

Next let's install Enemy Territory's best mod: ET Pro.
# cd /usr/ports/games/linux-enemyterritory-etpro
# make install clean
Now ET Pro will show under the Mods options in the games' main menu.

5) Update PunkBuster

Now start the game, create a player profile and quit. By doing so a .etwolf directory will be created in your home directory which includes a folder containing PunkBuster.

Point to http://www.evenbalance.com/index.php?page=pbsetup.php scroll down and follow the Linux download to download PunkBuster update application.

Change directory to where you've downloaded the pbsetup.run and:
# su
# chmod +x pbsetup.run
# exit
% cp pbsetup.run ~/.etwolf/pb
% ./pbsetup.run
PunkBuster will ask to fetch updates and prompt for a License Agreement. Afterwards point to "Add a Game option", choose Enemy Territory and its installation path.

On the main PunkBuster window click on Enemy Territory to select it and press "Check for Updates". Quit PunkBuster after updating it.

6) Install XQF

One can use the in game browser to search for server. However I recommend installing and using the XQF Game Server Browser as it a lot more flexible and complete:
# cd /usr/ports/games/xqf
# make install clean
XQF should identify the installed Enemy Territory so select the game and press "Update" to have XQF pull an updated server list.

I tend to play on www.Enemy-Territory.com by www.4netplayers.de server ;)

7) Fix sound issues

ET uses Linux's OSS sound infrastructure so you might come across issues. Here's how to enable sound on Enemy Territory under FreeBSD 7.x:
% su
# sysctl hw.snd.compat_linux_mmap=1
# echo "hw.snd.compat_linux_mmap=1" >> /etc/sysctl.conf
# exit
With the above commands sound will be enabled immediately and also at boot time.

8) Setup widescreen resolution

If you have a widescreen monitor follow the instructions on my previous blog post HowTo: Widescreen resolutions on Enemy Territory.

And we're done!

See you on the battlefield I'll be the one with the tangram"FreeBSD~ name :D

HowTo: Upgrade FreeBSD 7.1 to 7.2

Disclaimer: this post is for those that instead of using FreeBSD's excellent documentation maintain the bad habit of googling for things already covered in the project's official documentation. This is more or less a copy-paste of the FreeBSD 7.2-RELEASE Announcement instructions for upgrading 7.1 to 7.2.

These are needed steps to upgrade, through the binary upgrade method, the kernel and userland utilities to 7.2-RELEASE:
  1. % su
  2. # freebsd-update upgrade -r 7.2-RELEASE
  3. # freebsd-update install
  4. # shutdown -r now
  5. % su
  6. # freebsd-update install
  7. # shutdown -r now
On step 1 we've started of by becoming the superuser. Step 2 initiates the freebsd-update utility pointing the upgrade to 7.2-RELEASE, after that we proceed with the installation of the kernel on step 3.

Upon rebooting the new kernel is enabled and we move into step 6. Here we end the upgrade process by updating the userland utilities.

That's it!

If you found this post useful that's actually a bad news: you aren't reading the project's official documentation! So please point to http://www.freebsd.org and educate yourself on FreeBSD ;)

Wednesday, April 29, 2009

HowTo: Using DenyHosts to help thwart SSH attacks on FreeBSD

DenyHosts is a script intended to be run by UNIX-like system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).

I've used it before on Gentoo Linux and liked it, so today I'll lay out the steps required to install and configure it on FreeBSD:
  1. % su
  2. # cd /usr/ports/security/denyhosts
  3. # make install clean
  4. # echo 'denyhosts_enable="YES"' >> /etc/rc.conf
  5. # echo 'syslogd_flags="-s -c"' >> /etc/rc.conf
  6. # echo "sshd : /etc/hosts.deniedssh : deny" >> /etc/hosts.allow
  7. # echo "sshd : ALL : allow" >> /etc/hosts.allow
  8. # touch /etc/hosts.deniedssh
  9. Edit /usr/local/etc/denyhosts.conf and uncoment the BLOCK_SERVICE = sshd entry.
  10. # /usr/local/etc/rc.d/denyhosts onestart
Steps 1 to 3 deal with the installation procedure.

From step 4 to 9, rc.conf is updated so that DenyHosts is started at boot time and can act as a daemon monitoring SSH unauthorized login attempts registering them in hosts.deniedssh.

Finally, step 10 starts DenyHosts imediattely.

If you wish to learn more about DenyHosts have a look at the project's homepage at http://denyhosts.sourceforge.net.

Friday, April 24, 2009

HowTo: Enemy Territory on Gentoo Linux

Wolfenstein: Enemy Territory is a free multiplayer FPS that takes place in the World World II pitting two teams (Allies and Axis) against each other for victory.

In this post I'll detail the steps required to install and update Enemy Territory, the ET Pro mod, PunkBuster and XQF on Gentoo Linux.

1) Install and update Enemy Territory

Become the superuser:
$ su
And emerge the needed package:
# emerge enemy-territory
The game's License Agreement will appear to which you must press the q key so that the following prompt appears:
Do you accept the terms of this license (RTCW-ETEULA)? [yes/no]
Type yes.

Now start the game, create a player profile and quit. By doing so a .etwolf directory will be created in your home directory which includes a folder containing PunkBuster.

Inside the game you can check the installed version by pulling the console down by pressing ~ and typing version. It should output the following:
]\version
"version" is:"ET 2.60 linux-i386 Mar 10 2005" default:"ET 2.60 linux-i386 Mar 10 2005"
2) Install the ET Pro mod

To do so run:
# emerge enemy-territory-etpro
Now ET Pro will show under the Mods options in the games' main menu.

3) Update PunkBuster

Point to http://www.evenbalance.com/index.php?page=pbsetup.php scroll down and follow the Linux download to download PunkBuster update application.

Change directory to where you've downloaded the pbsetup.run and:
# su
# chmod +x pbsetup.run
# exit
$ cp pbsetup.run ~/.etwolf/pb
$ ./pbsetup.run
PunkBuster will ask to fetch updates and prompt for a License Agreement. Afterwards point to "Add a Game option", choose Enemy Territory and its installation path (/opt/enemy-territory).

On the main PunkBuster window click on Enemy Territory to select it and press "Check for Updates". Quit PunkBuster after updating it.

4) Install XQF

To browse and filter server I recommend installing and using the XQF Game Server Browser:
$ su
# emerge xqf
XQF will identify the installed Enemy Territory so select the game and press "Update" to have XQF pull an updated server list.

I tend to play on www.Enemy-Territory.com by www.4netplayers.de server ;)

5) Fix sound issues

ET uses Linux's OSS sound infrastructure so you might come across issues. If so please consult the Gentoo Linux Alsa Guide.

And we're done! See you on the battlefield :D

Wednesday, April 22, 2009

HowTo: Enemy Territory on Debian Linux

Wolfenstein: Enemy Territory is a free multiplayer FPS that takes place in the World World II pitting two teams (Allies and Axis) against each other for victory.

In this post I'll detail the steps required to install and update Enemy Territory, the ET Pro mod, PunkBuster and XQF on Debian GNU/Linux. As a bonus I'll also describe how to workaround sound problems with Enemy Territory on Debian 5.

These steps can be pretty much be reproduced in any Linux distribution. It should be noted that the steps were performed on Debian Lenny but should translate to newer releases.

1) Install and update Enemy Territory

Let's start by fetching the games' installer, make the downloaded file executable and run it to install the game:
$ wget -c http://ftp.freenet.de/pub/4players/hosted/et/official/et-linux-2.60.x86.run
$ su
# chmod +x et-linux-2.60.x86.run
#./et-linux-2.60.x86.run
Press OK in the popup.

Agree with the License Agreement by pressing ENTER at the License Agreement prompt and choosing YES on "Do you agree with the license?" popup that follows.

Choose NO at the "Would you like to read the CHANGES file?" popup. You can allways read the CHANGES file latter on if you want.

Choose the installation path. And press in the Symlink path popup press ENTER.

Install both Enemy Territory and Punkbuster by pressing the TAB key to move to the OK option.

The License Agreement for Punkbuster shows up. Press ENTER twice.

Choose to install the startup menu entries.

After this the game installs. Don't choose to start the game imediatlely as we haven't finished installing everything.

Now download its update:
$ wget -c http://darkstar.ist.utl.pt/games/et-2.60b.zip
Unzip the file:
$ unzip et-2.60b.zip
Change directory of the unziped directory and copy the update files to games' directory:
$ cd Enemy\ Territory\ 2.60b/linux
$ su
# cp * /usr/local/games/enemy-territory/
Logout from the root account:
# exit
Now start the game, create a player profile and quit. By doing so a .etwolf directory will be created in your home directory which includes a folder containing PunkBuster.

Inside the game you can check the installed version by pulling the console down by pressing ~ and typing version. It should output the following:
]\version

"version" is:"ET 2.60b linux-i386 May 8 2006" default:"ET 2.60b linux-i386 May 8 2006"
2) Install the ET Pro mod

Next let's install Enemy Territory's best mod: ET Pro.
$ wget -c http://bani.anime.net/etpro/etpro-3_2_6.zip
$ unzip etpro-3_2_6.zip
$ et
$ cp -R etpro ~/.etwolf
Now ET Pro will show under the Mods options in the games' main menu.

Note: If have other users using ET I suggest copying etpro to /usr/local/games/enemy-territory instead thus making the mod available to every user.

3) Update PunkBuster

Point to http://www.evenbalance.com/index.php?page=pbsetup.php scroll down and follow the Linux download to download PunkBuster update application.

Change directory to where you've downloaded the pbsetup.run and:
# su
# chmod +x pbsetup.run
# exit
$ cp pbsetup.run ~/.etwolf/pb
$ ./pbsetup.run
PunkBuster will ask to fetch updates and prompt for a License Agreement. Afterwards point to "Add a Game option" and choose Enemy Territory. Punkbuster will point the installation path to your username's .etwolf directory.

Note: If you want all your users to have Punkbuster updated run the above steps as root and point to the game's install directory which should be /usr/local/games/enemy-territory.

On the main PunkBuster window click on Enemy Territory to select it and press "Check for Updates". Quit PunkBuster after updating it.

4) Install XQF

To browse and filter server I recommend installing and using the XQF Game Server Browser:
$ su
# aptitude install xqf
XQF will identify the installed Enemy Territory so select the game and press "Update" to have XQF pull an updated server list.

I tend to play on www.Enemy-Territory.com by www.4netplayers.de server ;)

5) Fix sound issues

ET uses Linux's OSS sound infrastructure. If you don't have sound here's how to enable the needed kernel module at boot time:
$ su
# echo "snd_pcm_oss" >> /etc/modules
# modprobe snd_pcm_oss
And we're done! See you on the battlefield :D

Bonus section: etpro launch script

If you play etpro if can repeat the following steps to launch etpro directly (I'm assuming your shell is Bash):
$ echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
$ mkdir ~/bin
$ touch ~/bin/et-pro
$ chmod +x ~/bin/et-pro
$ vim ~/bin/et-pro
Add the following lines:
#!/bin/sh
cd "/usr/local/games/enemy-territory/"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
exec ./et.x86 "$@" +set fs_game etpro
Now you can launch etpro simply by:
$ et-pro

Thursday, April 16, 2009

Book Review: Building a Server with FreeBSD 7

I just love this book. Refreshing concept, clean, straight to the point and very very lean. In it you won't find any desktop related topics, this is an 100% server oriented book.

This is the book to get if you want to step up a server running services such as Apache, FTP, SAMBA, DNS, DHCP, NTP, VPN and so on. Chapter 1, presents the reader on clear and very straight to the option instructions on how to install FreeBSD and perform core administrative actions.

After this chapter we move to the core of the book: services. For here on the reader can choose the service he wants to install/configure and jump right to it.

For each service the author describes the application's background and history, software version used in the book, needed dependencies, install and configurations instructions. The book also shows how to test the service and points to further information. All this is a very systematic and streamlined manner.

BASWF7 is 288 pages long and makes a nice companion to set up services on FreeBSD for anyone acquainted with UNIX like systems. It's also a good complement to FreeBSD's own Handbook by moving into the territory where the Handbook falls short: third parties application configuration.

The book however isn't perfect. It should have in my opinion instructions on how to set up NFS and provide security hardening instructions/advice such as how to build a simple firewall to protect the server.

To sum up: I full hearty recommend this book to anyone wanting to build a server with FreeBSD.

Tip: D-Link DGE-528 on FreeBSD

Here's how to enable 1000baseTX full-duplex on a D-Link DGE-528 network card:
  1. % su
  2. # pciconf -lv
  3. # ifconfig
  4. # ifconfig -m re0
  5. # ifconfig re0 media 1000baseTX mediaopt full-duplex
  6. # vim /etc/rc.conf
  7. ifconfig_re0="inet 192.168.1.3 netmask 255.255.255.0 media 1000baseTX mediaopt full-duplex"
Start by becoming the superuser.

Steps 2, 3 and 4 help you determine where the card is (in my case re0) and collect more info on it.

On step 5 use ifconfig to apply the new setting and test the card out. If everything is ok add the ifconfig setting to /etc/rc.conf (steps 6 and 7) so that the next time you boot the next settings are applied.

Sources:
man 4 re
man 8 ifconfig

Wednesday, April 15, 2009

Tip: Fixing NVIDIA mismatched kernel module on Debian

I've installed Debian 5 Lenny a few day ago and imagine my surprise when yesterday I decided to update it and came across a broken Xorg.

Upon boot X11 didn't load and presented the following error message:
Failed to load the NVIDIA kernel module!
One of the updated packages was the Linux kernel, so I suspected that the problem was with the NVIDIA package and a mismatched Linux kernel.

I had nvidia-kernel-2.6.26-1-686 installed and the new kernel was 2.6.26-2-686 so I needed a matching NVIDIA kernel module.

So here are the steps that I took to fix things up:
  1. # aptitude search ~i~nvidia
  2. # aptitude update
  3. # aptitude purge nvidia-glx
  4. # aptitude install nvidia-kernel-2.6-686
  5. # aptitude install nvidia-glx
  6. # /etc/init.d/gdm restart
On step 1 let's us check exactly what we have installed related with nvidia. Next we update the apt's database and proceed removing the nvidia-glx on setp 3.

With steps 4 nvidia-kernel-2.6.26-2-686 and nvidia-kernel-common are pulled in and you'll be syncronized with the installed Linux kernel.

The nvidia-glx package is installed in step 5 and finnally gdm (replace gdm by the login manager you are using) is restarted bringing X11 back online.

And we're done. Bloodly kernel upgrades ;)

Thursday, April 9, 2009

Tip: Updating packages that don't want to be updated on Debian

In my desktop I have a series of operating systems including Debian GNU/Linux. Having spent most of my time in FreeBSD running XFCE4 I figured I'd update my Debian Sid install whose last update as performed more that 6 months ago.

So after performing apt-get update, apt-get upgrade and apt-get dist-upgrade a few packages insisted on not wanting to be updated with APT screaming "The following packages have been kept back".

A quick jump to the Debian's own APT HOWTO at http://www.debian.org/doc/manuals/apt-howto/index.en.html#contents presented some APT stuff that I were unaware.

So to know what's keeping a package from being updated you may use:
apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
Running this command helped me out in figuring what to do, which involved removing and re-installing some packages in a specific order.

APT does have some interesting thing into it doesn't it?

;)

Tuesday, March 24, 2009

Tip: Build ports on multiple processing cores

Ports framework supports building ports on multiple processing cores as announced today in the project's mailing list. This is achieved by passing -jX flag to make(1) running on vendor code.

Do notice that not all ports support this feature so ports that support this feature have their Makefile updated with MAKE_JOBS_SAFE=yes.

This feature is now enabled by default with the level of parallelization being equal to a number of processing cores in your computer. This value can however be overridden, for example if you want 6 jobs:
  • % su
  • # echo "MAKE_JOBS_NUMBER=6" >> /etc/make.conf
However if you want to disable this feature:
  • % su
  • % echo "DISABLE_MAKE_JOBS=yes" >> /etc/make.conf
You can read the announcement at http://lists.freebsd.org/pipermail/freebsd-ports/2009-March/053736.html.

HowTo: Install and configure NVIDIA drivers on FreeBSD

FreeBSD's Ports collection contains the official NVIDIA binary drivers for hardware OpenGL rendering in X, using the GLX extensions.The x11/nvidia-driver points to NVIDIA's latest stable driver set.

If you are using a legacy card check NVIDIA's site to see which driver set supports your card and browse the Ports tree for the suitable driver version and install that instead.

Bellow are the steps needed to install NVIDIA drivers on i386 FreeBSD 7.1:
  • % su
  • # portsnap fetch update
  • # cd /usr/ports/x11/nvidia-drivers
  • # make config
  • # make install clean
  • # echo 'nvidia_load="YES"' >> /boot/loader.conf
  • # echo 'linux_enable="YES"' >> /etc/rc.conf
  • # echo 'hint.agp.0.disabled="1"' >> boot/device.hints
Basically start by updating your ports tree, installing the driver and preparing FreeBSD to load the NVIDIA kernel module it at boot time. Consider selecting ACPI (enable support for ACPI Power Management) and LINUX (build with support for Linux compatibility) port options.

Now let's proceed by editing /etc/X11/xorg.conf to have it use the NVIDIA driver and add some options to increase performance:
  • edit /etc/X11/xorg.conf and change the driver value from "nv" to "nvidia":
Driver "nvidia"
  • under the Device section of xorg.conf add the following option:
Option "NvAGP" "1"
Additional performance options can be enabled, however these might affect stability. To enable Side Band Addressing and Fast Writes add the following sysctls to /etc/sysctl.conf:
  • # echo "hw.nvidia.registry.EnableAGPSBA=1" >> /etc/sysctl.conf
  • # echo "hw.nvidia.registry.EnableAGPFW=1" >> /etc/sysctl.conf
Finally:
  • # reboot
Further reading material can be found at:
http://www.freebsd.org/doc/en/books/handbook/x11.html
/usr/local/share/doc/NVDIA_GLX-1.0/

Monday, March 23, 2009

Tip: Use SUB_LIST to discover a port's VAR paths on FreeBSD

I was looking for man pages, READMEs and assorted information on the nvidia-driver port and couldn't recall where I'd seen the port's installed documentation.

Enter SUB_LIST for the rescue:
  • % cd /usr/ports/x11/nvidia-driver
  • % make -V SUB_LIST
PREFIX=/usr/local LOCALBASE=/usr/local X11BASE=/usr/local DATADIR=/usr/local/share/nvidia-driver DOCSDIR=/usr/local/share/doc/NVIDIA_GLX-1.0 EXAMPLESDIR=/usr/local/share/examples/nvidia-driver WWWDIR=/usr/local/www/nvidia-driver ETCDIR=/usr/local/etc/nvidia-driver
SUB_LIST kindly outputs a list of VAR=VALUE pairs, showing useful information such as PREFIX and DOCSDIR.

Pretty nice eh? ;)

Point to http://www.freebsd.org/doc/en/books/porters-handbook/using-sub-files.html for further information on ports and SUB_LIST.

HowTo: Fix SATA DMA timeout issues on FreeBSD

Update: added instructions for those using FreeBSD 8.x.

I've experienced heavy problems with a recently purchased 1TB SATA drive from Samsung on ICH7 motherboard running a fresh FreeBSD 7.1 install. The system was issuing loads of SATA timeout errors that culminated in system crashes, drive disconnection and data loss.

Here's a snip of my /var/log/messages:
kernel: ad4: WARNING - WRITE_DMA UDMA ICRC error (retrying request) LBA=26003999
kernel: ad4: WARNING - WRITE_DMA UDMA ICRC error (retrying request) LBA=56856991
kernel: ad4: WARNING - WRITE_DMA UDMA ICRC error (retrying request) LBA=57609503
kernel: ad4: TIMEOUT - READ_DMA retrying (1 retry left) LBA=174249023
kernel: ad4: TIMEOUT - READ_DMA retrying (1 retry left) LBA=190428031
kernel: ad4: WARNING - WRITE_DMA48 UDMA ICRC error (retrying request) LBA=1351930207
kernel: ad4: TIMEOUT - WRITE_DMA48 retrying (0 retries left) LBA=1351930207
Upon searching for solutions I came across Jeremy Chadwick's page on wiki.freebsd.org. Jeremy has been registering issues that are commonly reported by FreeBSD users and also published troubleshooting methods for ATA/SATA issues.

Jeremy informs that Volker Theile of the FreeNAS project had solved most of the problems by increasing a hard-coded arbitrary timeout value of 5 (seconds) in the ATA code to 10 or 15, while simultaneously making the timeout value adjustable via sysctl.
So I thought to myself "Might as well try the patch out and hope for the best". And I'm glad that I went along and tried it out as it fixed all of my issues.

Bellow are the needed steps to fetch the patch, apply it and compile a patched kernel:

  1. % fetch http://freenas.svn.sourceforge.net/viewvc/freenas/trunk/build/kernel-patches/ata/files/patch-ata.diff
  2. % su
  3. # csup -h cvsup2.uk.freebsd.org -L 2 /usr/share/examples/cvsup/standard-supfile
  4. # cd /usr/src/sys/dev
  5. # patch < /path/to/patch
  6. # cd /usr/src
  7. # make kernel
  8. # cp -Rp /boot/kernel.old /boot/kernel.SATA-ISSUES
  9. # reboot
Start by fetching the patch (step 1), next change to root and fetch FreeBSD's source code as detailed in step3.

Note: if you are running FreeBSD 8.x fetch the patch file using this URL instead http://www.avenard.org/files/ata_timeout.patch. Replace the step 1 URL with this one.

Next, with steps 4 and 5 patch the source code with FreeNAS' patch and build a patched kernel. Do notice that I used csup pointing to /usr/share/examples/cvsup/standard-supfile as I'm running FreeBSD 7.1 (of simply use your own supfile). Further information on how to build a kernel can be found at http://www.freebsd.org/handbook/kernelconfig.html.

As a safety precaution back up the old kernel as described in step 9.

Finally reboot to the new kernel and monitor /var/log/messages for SATA timeout issues. After I've applied the patch my problems have stopped.

Props to:
Jeremy Chadwick and Volker Theile for the FreeBSD 7.x patch.
Jean-Yves Avenard for providing the URL a FreeBSD 8.x patch.

Tuesday, March 17, 2009

Tip: Add color to man pages with most on FreeBSD

man pages are formatted using FreeBSD less and more utilities which display text in blank and white colors. most on the other hand introduces the ability to view man pages formatted with colors.

most is a pager (like less and more) that displays, one windowful at a time, the contents of a file on a terminal. It pauses after each windowful and prints the following on the window status line: the screen, the file name, current line number, and the percentage of the file so far displayed.

Let's install most:
  • % su
  • # cd /usr/ports/sysutils/most
  • # make install clean
  • # rehash
  • # exit
Users of csh or tcsh shells can try most out by setting the PAGER environment variable like so:
  • % setenv PAGER most
Those that use the zsh shell can set the PAGER environment variable like this:
  • % export PAGER=most
If you like it editing you user shell configuration file and set the PAGER variable to most.

As most is a third party application I'd suggest that you don't use it as the default pager for the root account. I'm sure you don't want to find yourself in single user mode with only the root partition mounted and realize that your .cshrc defines most has the pager ;)

Wednesday, March 11, 2009

HowTo: Determine the fastest CVSup mirror on FreeBSD

fastest_cvsup is a Perl script to find fastest CVSup server. Amongst it's feature it:
  • uses socket connections not just 'pings'
  • takes notice of server responses
  • connects to servers in countries specified on the command line - or - connects to the 'local' servers defined in the script - or - connects to ALL the servers in ALL the countries
  • returns either fastest server or top 3 (useful for scripts)
  • returns exit codes (useful for scripts)
  • can re-write itself to update the CVSup server list, obtained from the online FreeBSD Handbook
  • can easily add other CVSup servers (NetBSD/OpenBSD...etc)
Here's how to identify the fastest CVSup mirror:
  1. % su
  2. # cd /usr/ports/sysutils/fastest_cvsup
  3. # make install clean
  4. # rehash
  5. # exit
  6. % fastest_cvsup -Q -r -c all
We've started by becoming the superuser, proceeded by installing the port and finally ran it. After running the last command, the application will prompt the fastest mirror.

Change your /etc/make.conf or supfiles with the new mirror. In alternative pass the determined mirror at the command line when running csup.

For more options run:
  • % fastest_cvsup -h
  • % man fastest_cvsup
Some further examples of the script's usage:
  • times the FreeBSD CVSup servers in the United Kingdom, France and Germany:
% fastest_cvsup -c uk,fr,de
  • times the OpenBSD and NetBSD CVSup servers:
% fastest_cvsup -c openbsd,netbsd
  • shell script, finds the fastest UK FreeBSD CVSup server, then runs csup using that server:
#!/bin/sh
if SERVER=`fastest_cvsup -q -c uk`; then
csup -h $SERVER /usr/share/examples/cvsup/standard-supfile
fi
The project's website can be found at http://fastest-cvsup.sourceforge.net/.

Monday, March 9, 2009

Tip: Enable sudo completion in tcsh/csh shell

Having installed and setup sudo I realized that the C shell (e.g. tcsh/csh) didn't autocomplete commands issued after typing sudo.

Place the following in your .cshrc file:
set complete = enhance
complete sudo 'n/-l/u/' 'p/1/c/'
And finally source the changes:
% source .cshrc
For more information visit tcsh(1) in the REFERENCE section under complete.

Tip: Allow users to shutdown the system on FreeBSD

Operations such as shutdown and rebooting usually require root privileges. However, one may allow other users to run these commands with success.

To allow users to shutdown a FreeBSD system you basically have two options: add the user to the operator group or install and configure sudo to allow usage of the administrative command. I've already covered the latter option in a previous post so I'll only go over the remaining option here.

The steps consist in becoming root and using pw to add the user (in the example bellow username) to the operator group:
% su
# pw groupmod operator -m username
# exit
To reboot the system login to the user account that belongs to the operator group and run:
% shutdown -r now
If you want to power down the system run this instead:
% shutdown -p now
Do take a look at pw(8) and shutdown(8) manual pages for further information.

Friday, March 6, 2009

Tip: Solving the sudo redirect "problem"

Upon using sudo more frequently I came across an issue while using redirects, for example:
% sudo echo WITHOUT_IPFILTER=yes > /etc/make.conf
root: Permission denied.
The key to solve the "problem" was to run the command in a sub-shell to make the redirection work, like so:
% sudo sh -c 'echo WITHOUT_IPFILTER=yes > /etc/make.conf'
The answer to this lies in man sudo ;)

Thursday, March 5, 2009

HowTo: Using sudo on FreeBSD

sudo is a great tool for granting specific privileges to users other that the root user. This application allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

Today I'll detail the steps needed to install and configure sudo on FreeBSD from a desktop/workstation perspective, in other words I'll dwell more on less on the common user.

Let's start by install the application and then proceed to configure the sudoers file with visudo:
  1. % su
  2. # cd /usr/ports/security/sudo ; make install clean
  3. # visudo /usr/local/etc/sudoers

Uncomment the following line to allow users in the wheel group to run all commands:
%wheel ALL=(ALL) ALL
By enabing this line, users in wheel group will have full root privileges on the computer by providing their password in order to use administrative commands.

If you wish that users in the wheel to acquire these privileges without using a password then uncomment the next line instead:
%wheel ALL=(ALL) NOPASSWD: ALL
sudo can also be used to allow more restrictive usage, for instance to allow the user freebsduser to mount and unmount /cdrom the following line could be added to /usr/local/etc/sudoers:
freebsduser ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
To allow members of the users group shutdown the computer add the following to the sudoers file:
%users localhost=/sbin/shutdown -h now
Add the following line to let user freebsduser access all privileges without entering password:
freebsduser ALL=(ALL) NOPASSWD: ALL
After editing the sudoers file you'll need to issue a :w! command in visudo as the file is read-only. To use sudo just prefix sudo before the command with specific privileges. For the %wheel ALL=(ALL) ALL example, if you are in the wheel group and want to shutdown the computer you'd type:
# sudo shutdown -h now
And insert your passoword.

Once you enter a correct passwo
rd, sudo records the time and for the next 5 minutes it won't ask you for a password. After those 5 minutes you must re-authenticate. You can change the timeout value from 5 to another value by setting the password_timeout value in the /usr/local/etc/sudoers file).

Every use of sudo is logged in /var/log/messages, so do take a look and check for yourself.

I've only touched the tip of the iceberg on sudo so do take a look at its man page.

Tuesday, March 3, 2009

Tip: Disable OpenOffice splash screen in FreeBSD

With time OpenOffice's splash screen becomes annoying so end up disabling it on all my machines. Today in FreeBSD mailing list I replied to fellow user who was asking on how to due this on FreeBSD so thought I should share the tip here also.

Here are the needed steps:
  1. % su
  2. # vim /usr/local/openoffice.org-3.0.0/openoffice.org3/program/sofficerc
  3. Change the Logo variable from 1 to 0 like so
[Bootstrap]
Logo=0
We've started by becoming the superuser on step 1, and proceeded to change the Logo variable value defined in /usr/local/openoffice.org-3.0.0/openoffice.org3/program/sofficerc so that the splash is disabled.

If by any chance you want to renable the splash screen just change the Logo variable value back to 1.

Simple eh?

;)

Monday, February 9, 2009

Tip: Fix keyboard layout problem with Xorg Server 1.5.3 under FreeBSD

The Xorg Server was updated to version 1.5.3 and with it came much controversy.

I had a nice xorg.conf customized for my hardware and it served me for over a year, however all of a sudden my keyboard layout options weren't read by Xorg. The way input devices were configured in Xorg changed, now being configured by hal.

Browsing the mailing lists, /usr/ports/UPDATING and forum I came across several solutions here's the one I decided to implement:
  1. % su
  2. # vi /etc/xorg.conf
Section "ServerFlags"
Option "AllowEmptyInput" "off"
Option "AutoAddDevices" "off"
EndSection
Basically I've edited xorg.conf and added options to disable Xorg's use of hal features. Do take notice that I use a window manager (lately Fluxbox) so I don't need hal.

Anyone needing hal will need to resort to other options. Browse FreeBSD's mailing lists between late January and early February for more info.

Thursday, January 29, 2009

Tip: Mount ReiserFS partitions in FreeBSD

My desktop dual boots Gentoo Linux and FreeBSD. When I installed Gentoo at the time I decided on splitting certain directories in distinct partition, so then I created a partition strictly for portage and opted for the ReiserFS filesystem.

Today I wanted to cut down on the bandwith and decided to copy over a needed distfile from the ReiserFS partition to FreeBSD.

Bellow you'll find the procedure to mount a ReiserFS in read-only mode. Do notice than the entire procedure is performed only on the FreeBSD system:
  1. % man reiserfs
  2. % su
  3. # kldload reiserfs.ko
  4. # mount -t reiserfs -o ro /dev/ad4s5 /mnt
On step 1 read reiserfs' man page, next become the superuser and proceeded to load the kernel module and finally mount the filesystem.

The -t switch lets you specify the filesystem and with -o decide in which mode should the filesystem be mounted (in this case in read-only mode).

My target partition was /dev/ad4s5 so change accordingly to your system. In my case I just viewed Gentoo's /etc/fstab and ran ls /dev/ad* to check if it added up ok.

Pretty simple eh?

Monday, January 26, 2009

Book Review: Absolute FreeBSD: The Complete Guide to FreeBSD, 2nd Edition

In the past holidays I bought a few books about FreeBSD: Absolute FreeBSD: The Complete Guide to FreeBSD 2nd Edition, The Best of FreeBSD Basics, The Book of PF and Building a Server with FreeBSD 7.

I'm pretty happy with all of them and I recommend them, under certain criteria, to anyone looking into FreeBSD. Why under certain criteria? If you're looking for a book on desktop usage of FreeBSD you'll find The Book of PF pretty disapointing.

Absolute FreeBSD: The Complete Guide to FreeBSD, 2nd Edition is the perfect combination for FreeBSD's own Handbook. At times the Handbook might seem too straightforward by not offering advices or sharing experiences. Michael Lucas' Absolute FreeBSD on the other hand presents the reader with rich information, background, advice and reasoning although focusing on the network administrator and setting aside the desktop user.

If you are looking into a nice FreeBSD book to get your feet wet on Unix-like systems so that you can carry out mundane desktop tasks then I'm afraid that Absolute FreeBSD simply isn't for you. If you on the other hand enjoy FreeBSD, know Unix basics and want to expand your horizons and maybe setup a personal server and even make a living out of FreeBSD, Absolute FreeBSD is definitely for you.

I don't have an IT background though I know my way around Unix-like systems so I've found chapters like Chapter 6: The Network extremely useful to cement some disperse concepts that I have (had thanks to Lucas' book).

People new to FreeBSD and Unix-like systems in general will find the first two chapters filled with helpful advices on how to prepare yourself for the tasks of installing FreeBSD and seeking help, especially the Preinstall Decisions section. To help explore FreeBSD Chapter 10: Exploring /etc is simply golden as it goes over the files available in /etc while describing what each does.

I found Chapter 3: Start me Up! The Boot Process very insightful. Chapter 4 brought RCS to my bag of tricks. The security chapters (7 and 9) were also very interesting reading namely the part regarding Jails.

Personal favorites were Chapter 5: Kernel Games, Chapter8: Disks and Filesystems, Chapter 11: making your system useful, Chapter 12: Advanced Software Management, Chapter 13: Upgrading FreeBSD, Chapter 18: Disk Tricks with GEOM. These are the chapters I'll ended reading time and time again and are largely FreeBSD focused.

Chapters 15 and 17 focus on adding services to FreeBSD and go over SSH, FTP, NTP, Inetd and Apache web server. Pretty useful as I'm planning on setting up some personal web serving stuff.

I'm not much into email and DNS stuff so I didn't payed much attention to chapters 14 and 16, however if the reader is into the subjects I'm sure he'll find both chapters very important.

Props to chapter 20, 21 and the Afterword expand on what FreeBSD is, what it can be, how can you interact with it and what can you do to improve it.

To sum up, just go out and buy the book. It's worth every penny and more.

Tuesday, January 20, 2009

Tip: Remove all installed packages and ports on FreeBSD

This post provides the steps required to remove every installed package and port on a FreeBSD system. By following the bellow steps you'll end up with a barebones system composed by FreeBSD's userland and kernel without any third party applications.
  1. % su
  2. # pkg_delete -f -a
  3. # rm -rf /var/db/pkg /var/db/ports /usr/local
We've started by using pkg_delete to remove all packages and ports and finished by deleting every traces of them in the system (including ports selected build options).

And that's it!

Monday, January 19, 2009

HowTo: Using ccache on FreeBSD

ccache is a compiler cache. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile is being done again.

The following is a step by step guide to how to enable and use ccache on FreeBSD 7.1:
  1. % su
  2. # cd /usr/ports/devel/ccache
  3. # make install clean
  4. # vim /etc/make.conf
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*)) && !defined(NOCCACHE)
CC=/usr/local/libexec/ccache/world-cc
CXX=/usr/local/libexec/ccache/world-c++
.endif
Basically we've started by installing ccache (steps 1 through 3) and proceeded by editing /etc/make.conf as to enable ccache on builds.

Now we need to update the environment.

If you are using csh/tcsh shell add the following to /root/.cshrc:
setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin
setenv CCACHE_DIR /var/tmp/ccache
setenv CCACHE_LOGFILE /var/log/ccache.log
If you are using zsh add the following to your /root/.zshrc file:
export PATH=/usr/local/libexec/ccache:$PATH
export CCACHE_PATH=/usr/bin:/usr/local/bin
export CCACHE_DIR=/var/tmp/ccache
export CCACHE_LOGFILE=/var/log/ccache.log
After updating the dotfiles we update the environment. Users of csh/tcsh shells can update by:
  • # source /root/.cshrc
Anyone using zsh can update the environment by running the following command:
  • # source /root/.zshrc
And that's it: ccache is installed and the environment is updated. Your next build will be performed with ccache enabled.

To display statistics summary:
  • % ccache -s
To zero statistics:
  • % ccache -z
To check out the help file for a list of ccache options:
  • % ccache -h
If you come across a port that fails to build, disable ccache and try again:
  • # make NOCCACHE=yes install clean
You can find more information regarding ccache through:

Thursday, January 15, 2009

Tip: Disable beep in Fedora

The first thing I realized I just had to change on Fedora 10 was the bloody beep. Fedora ships with a kernel module for the PC speaker named pcspkr.ko that if left loaded will drive you mad.

With this module loaded you get to hear a lovely beep while using a terminal. To turn off the beep, simply remove the kernel module and blacklist it to have it gone for good.

Here's how:
  1. $ su
  2. # rmmod -v pcspkr
  3. # echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist
On step 1 become superuser, on step 2 we've removed the module for the running session and on step 3 we've prevented it from loading at boot.

These steps can be performed similarly in other distros.

Tip: Disable shutdown beep in FreeBSD

Beeps are annoying and the one at shutdown is no different.

Here's how to get rid of shutdown beeps:
  1. % su
  2. # sysctl hw.syscons.bell=0
  3. # echo "hw.syscons.bell=0" >> /etc/sysctl.conf
  4. # exit
We've started by becoming the superuser and then on step 2 we've disable the console bell. To guarantee that on next boot that horrible beep doesn't crop up we've added a sysctl to disable it in /etc/sysctl.conf.

Tuesday, January 13, 2009

Tip: Log console messages in FreeBSD

If you run FreeBSD without X11 you've noticed already that messages are presented in the console. Well you can log these messages with the help of syslog.

Here's how:
  • % su
  • # touch /var/log/console.log
  • # chmod 600 /var/log/console.log
  • # vim /etc/syslog.conf
Make sure that that the console.info /var/log/console.log is uncommented.
  • # /etc/rc.d/syslogd restart
And that's it!

Wednesday, January 7, 2009

HowTo: Upgrade FreeBSD 7.0 to 7.1

Disclaimer: this post is for those that instead of using FreeBSD's excellent documentation maintain the bad habit of googling for things already covered in the project's official documentation. This is more or less a copy-paste of the FreeBSD 7.1-RELEASE Announcement instructions for upgrading 7.0 to 7.1.

These are needed steps to upgrade, through the binary path, the kernel and userland utilities to 7.1-RELEASE:
  1. % su
  2. # freebsd-update upgrade -r 7.1-RELEASE
  3. # freebsd-update install
  4. # reboot
  5. % su
  6. # freebsd-update install
  7. # reboot
On step 1 we've started of by becoming the superuser. Step 2 initiates the freebsd-update utility pointing the upgrade to 7.1-RELEASE, after that we proceed with the installation of the kernel on step 3.

Upon rebooting the new kernel is enabled and we move into step 6. Here we end the upgrade process by updating the userland utilities.

That's it!

If you found this post useful that's actually a bad news: you aren't reading the project's official documentation! So please point to http://www.freebsd.org and educate yourself on FreeBSD ;)