Monday, May 28, 2012

HowTo: Mount UFS partition on CentOS / SL 6.2

By default RHEL clones such as CentOS and Scientific Linux don't come with UFS filesystem support.

However the ELRepo repository has the kmod-ufs package which provides the much needed kernel module. As such enabling ufs support on RHEL/CentOS/SL 6.2 consists of adding the ELRepo repository, installing and loading the kernel module for UFS.

The required steps are:
  1. $ su
  2. # rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org
  3. # rpm -Uvh http://elrepo.org/elrepo-release-6-4.el6.elrepo.noarch.rpm
  4. # yum update
  5. # yum install kmod-ufs
  6. # modprobe ufs

Now that we have kernel support for UFS let's proceed to identify the partition(s) with UFS filesystems:
  1. # fdisk -l /dev/sdb
 
 Disk /dev/sdb: 203.9 GB, 203928109056 bytes  
 255 heads, 63 sectors/track, 24792 cylinders  
 Units = cylinders of 16065 * 512 = 8225280 bytes  
 Sector size (logical/physical): 512 bytes / 512 bytes  
 I/O size (minimum/optimal): 512 bytes / 512 bytes  
 Disk identifier: 0x90909090  
   Device Boot   Start     End   Blocks  Id System  
 /dev/sdb1        1    1968  15807928+  7 HPFS/NTFS  
 /dev/sdb2      1969    7067  40957717+ a5 FreeBSD  
 /dev/sdb3  *    7068    12166  40957717+ a5 FreeBSD  

In the BSD world slices are subdivided into partitions. Where Linux fdisk sees a FreeBSD partition that partition is in fact a BSD slice with internal partitions. Taking a peek at the output of /var/log/messages helps in identifying which are partitions that can be mounted.

For example in my system:

  1. # grep /dev/sdb /var/log/messages
 May 24 21:44:33 athon kernel: sda5 sdb2: <bsd: sdb5 sdb6 sdb7 sdb8 sdb9 >  
 May 24 21:44:33 athon kernel: sda6 sda7 sda8 sdb3: <bsd: sdb10 sdb11 sdb12 sdb13 >  
 May 28 19:39:09 athon kernel: sda5 sda6 sdb2: <bsd: sdb5 sdb6 sdb7 sdb8 sdb9 >  
 May 28 19:39:09 athon kernel: sda7 sda8 sdb3: <bsd: sdb10 sdb11 sdb12 sdb13 >  

What does this mean? sdb2, sdb3, sdb5, sdb6, sdb7, sdb8, sdb9, sdb10, sdb11, sdb12 and sdb13 are FreeBSD UFS partitions.

To mount a FreeBSD UFS partition:
  1. # mount -t ufs -o ufstype=ufs2,ro /dev/sdb2 /mnt/

In which -t ufs -o ufstype=ufs2,ro identify the UFS filesystem as being UFS2 and mounted as read-only.

Sunday, May 20, 2012

HowTo: Enemy Territory on x86_64 CentOS 6.2 / SL 6.2

Update 21/05/2012:
I'm getting Punkbuster kicked out of the game by random game integrity violations. I'm trying to identify a solution, until then I figure what's wrong I can't recommend following this how-to.
If you're reading this and manage to fix the problem, please let me know in the comments.
Update 04/06/2012:
Installed ET on Ubuntu 12.04 x86_64 both the manual way and using the get-deb package and the result is the same: random PB kick on servers running Punkbuster.

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 on 64-bit CentOS, namely:
1) Download the necessary files
2) Install i686 libraries
3) Install and update Enemy Territory
4) Install updated Punkbuster files
5) Generate an etkey
6) Fix sound problem
7) Setup widescreen resolution
8) Bonus section: troubleshooting

It should be noted that the steps were performed on CentOS 6.2 x86_64 thus should translate to RHEL and Scientific Linux..

1) Download Enemy Territory 2.60 and 2.60b update

Download et-linux-2.60.x86.run, et-2.60b.zip update, updated Punkbuster and the et-sdl-sound.gz sound fix: 
  1. $ wget -c http://ftp.freenet.de/pub/4players/hosted/et/official/et-linux-2.60.x86.run
  2. $ wget -c ftp://ftp.idsoftware.com/idstuff/et/ET-2.60b.zip
  3. $ wget -c http://etkey.org/et_linux.zip
  4. $ wget -c http://nullkey.kapsi.fi/~stuff/et-sdl-sound/et-sdl-sound.gz

2) Install i686 libraries

Enemy Territory is a 32-bit application as such for a 64-bit CentOS a few i686 libraries are needed:
  1. # yum install glibc.i686 libX11.i686 libXext.i686 libstdc++.i686 pulseaudio-libs.i686

Enemy Territory requires 3D acceleration which commonly implies NVIDIA or AMD/ATI graphic cards and associated proprietary drivers.

User of NVIDIA cards are required to install nvidia-x11-drv-32bit which provides the compatibility 32-bit files for the 64-bit proprietary NVIDIA driver:
  1. # yum install nvidia-x11-drv-32bit

I'd assume that users of AMD/ATI graphics card need to install fglrx-x11-drv-32bit which provides similar files for the proprietary AMD driver, however I don't have an AMD/ATI card to verify.

3) Install and update Enemy Territory

Change to root, attribute execute permissions to the installer, install Enemy Territory 2.60, install the 2.60b update, create a profile and check the game's version:
  1. $ su
  2. # chmod +x et-linux-2.60.x86.run
  3. #./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 always read the CHANGES file latter on if you want. Choose the installation path and press OK in the Symlink Path popup. Install both Enemy Territory and Punkbuster. Choose to install the startup menu entries. After this the game installs. Don't choose to start the game immediately as we haven't finished installing everything.

Install the 2.60b update:
  1. # unzip et-2.60b.zip
  2. # cp Enemy\ Territory\ 2.60b/linux/* /usr/local/games/enemy-territory/
  3. # exit

Now start the game, create a player profile identifying profile name, connection speed and clicking on Enable Punkbuster; exit the game. 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"  

4) Install updated Punkbuster files

Remove old Punkbuster files, extract the last Punkbuster update and place it in the created profile:
  1. $ rm -rf ~/.etwolf/etmain/pb
  2. $ unzip et_linux.zip -d pb
  3. $ cp -R pb ~./etwolf/etmain/

5) Generate an etkey

Point to http://etkey.org/pages/etkey-home.php, press the Get an ETKEY button, download the file and store it under ~./etwolf/etmain/.

6) Fix sound problem

The most dreadful any Linux Enemy Territory player can witness:
 ------- sound initialization -------  
 /dev/dsp: No such file or directory  
 Could not open /dev/dsp  
 ------------------------------------  
Luckily we can use the SDL backend which Enemy Territory will use as audio device replacing /dev/dsp and OSS.

Install SDL, extract the et-sdl-sound script, make it executable and accessible to all and edit the et launcher to have Enemy Territory use SDL instead of OSS:
  1. # yum install SDL.i686
  2. # gzip -d et-sdl-sound.gz
  3. # chmod a+x et-sdl-sound
  4. # chown root:root et-sdl-sound
  5. # mv et-sdl-sound /usr/local/games/enemy-territory/
  6. # vim /usr/local/games/enemy-territory/et

 #!/bin/sh  
 # Needed to make symlinks/shortcuts work.  
 # the binaries must run with correct working directory  
 cd "/usr/local/games/enemy-territory/"  
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.  
 ./et-sdl-sound "$@"  

The et-sdl-sound script needs to be edit so that PulseAudio is used has the SDL audio driver.
  1. # vim /
    usr/local/games/enemy-territory/et-sdl-sound
 Replace  
 SDL_AUDIODRIVER="alsa"  
 with  
 SDL_AUDIODRIVER="pulse"

7) 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 installing Enemy Territory!

Lately I've been playing at [fp].:Demolition_Centre as tangram"FreeBSD~ or tangram"GNU/Linux~. See you on the battlefield :D

8) Bonus section: troubleshooting

Error:
 /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory  
  1. # yum install glibc.i686

Error:
 ./et.x86: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory  
  1. # yum install libX11.i686

Error:
 ./et.x86: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory  
  1. # yum install libXext.i686

Error:
 ----- Client Initialization Complete -----  
 ----- R_Init -----  
 ...loading libGL.so.1: QGL_Init: dlopen libGL.so.1 failed: libGL.so.1: cannot open shared object file: No such file or directory  
 failed  
 ----- CL_Shutdown -----  
 RE_Shutdown( 1 )  
 -----------------------  
 ----- CL_Shutdown -----  
 -----------------------  
 Sys_Error: GLimp_Init() - could not load OpenGL subsystem  
  1. # yum install nvidia-x11-drv-32bit

or
  1. # yum install fglrx-x11-drv-32bit

Saturday, May 19, 2012

HowTo: Install VirtualBox on CentOS 6.2 / SL 6.2

Oracle VM VirtualBox is an popular software package that once installed on an existing host operating system allowing for additional guest operating systems to be loaded and run, each with its own virtual environment.

In this post I'll go over the steps needed to install it on RHEL clones such as CentOS and Scientific Linux.

In summary, we start by downloading VirtualBox's YUM repository file and placing it in the appropriate directory, afterwards we install the dkms and VirtualBox-4.1 packages and conclude by adding your user to be vboxusers group.

Let's begin by fetching the repo file and placing it under /etc/yum.repos.d/:
  1. $ wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
  2. $ su
  3. # mv virtualbox.repo /etc/yum.repos.d/

Afterwards, installing dkms will bring in cloog-ppl, cpp, gcc, glibc-devel, glibc-headers, kernel-devel, kernel-headers, libgomp, make, mpfr and ppl. These are needed to have VirtualBox match the kernel.
  1. # yum install dkms

Then we move to installing VirtualBox itself.

For 32 bits systems use:
  1. # yum install VirtualBox-4.1.i686

In the case of 64 bits systems:
  1. # yum install VirtualBox-4.1.x86_64

Wrap up by adding your user to the vboxusers and rebooting the computer:
  1. # usermod -a -G vboxusers ricardo
  2. # reboot

Just in case, make sure to check and see if your computer BIOS has virtualization support disabled. More often that not, motherboard have it disabled.

HowTo: Install Dropbox using Repoforge on CentOS 6.2 / SL 6.2

Dropbox is a Web-based file hosting service that uses networked storage provided by Dropbox, Inc to enable users to store and share files and folders with others across the Internet using file synchronization.

The good folks that maintain the Repoforge (also know as RPMforge) repository have added packages for Dropbox.

What does this mean? No need for workaround for using Dropbox's Fedora repository on CentOS / SL / RHEL.

This post assumes that you already have a Dropbox account, if you don't get one here.

If you're running a 32 bits system:
  1. $ su
  2. # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  3. # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
  4. # yum install nautilus-dropbox

On the other hand, if you have a 64 bits install issue the following commands:
  1. $ su
  2. # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  3. # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  4. # yum install nautilus-dropbox
  5. # echo '-b /usr/libexec/dropbox/' >/etc/prelink.conf.d/dropbox.conf

Users of 64 bit systems are required an extra step otherwise Dropbox will fail after reboot because prelink 'optimises' executables during bootup, however Dropbox has issues with those optimizations.

As part of installing the rpm package you'll be forced to restart Nautilus, afterwards point to Applications -> Internet and launch the new Dropbox entry.

A series of Dropbox installation windows will guide you during the rest of the setup.

To wrap-up add the username(s) that will use Dropbox on /etc/sysconfig/dropbox. For example, if the users that will use Dropbox are john and jane:

  1. # vim /etc/sysconfig/dropbox
  2. DROPBOX_USERS=john,jane

Now be patient, in a matter of minutes you'll have a synchronized Dropbox folder :)

HowTo: Install Adobe Flash Player on CentOS 6.2 x86_64

Update 15-07-2012: the folks at the Repoforge have added flash-plugin to their repository. If you prefer to use their package follow the instructions at http://linux-bsd-sharing.blogspot.pt/2012/07/howto-install-adobe-flash-player-using.html.
 
Ever since I've upgraded my Dell D620 from an Intel Core Duo T2300E to a Core 2 Duo T7200 I've grown to be "64 bits conscious". As a result today I'll explain how to install Adobe Flash Player in CentOS 6.2 x86_64.

To install Adobe Flash Player on a RHEL 6.2 clone, you'll need to change to root, install Adobe's YUM repository, import the associated GPG key and install Adobe Flash Player for x86_64.

For a 64 bits CentOS 6.2 installation, run the following commands:

  1. $ su
  2. # rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
  3. # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
  4. # yum install flash-plugin

If you're running i386 you can install Adobe Flash Player following the instructions I've laied out here.

Launch Mozilla Firefox and in the address bar enter about:plugins. An Shockwave Flash entry should be available.

If you point to System -> Preferences you'll notice that a new entry named Adobe Flash Player is now available.

You can test if the plugin is working by visiting http://www.adobe.com/software/flash/about or by firing up a random Youtube clip.

Sunday, May 13, 2012

HowTo: Install and run NetBSD on Virtualbox

NetBSD attracts me.

Maybe it's the philosophy being it... or maybe it just the old BSD daemon holding the flag on top of computer. Regardless of the reason, I've been toying with the idea of installing NetBSD on my Athon XP 3200+ nForce2 old desktop for a while now.

However the only instructions I found to convert a NetBSD 5.1.2 CD image into an USB bootable install medium involved using NetBSD. This chicken-egg dilema lead me to VirtualBox 4.1.14.

Just a few seconds after booting the install image into the VirtualBox machine it kernel panicked with the following error:
 uvm_fault(0xc0b82a00, 0, 1) -> 0xe 
 fatal page fault in supervisor mode 
 trap type 6 code 0 eip c0100d27 cs 8 eflags 3046 cr2 0 ilevel 1 
 kernel: supervisor trap page fault, code=0 
 Stopped in pid 0.19 (system) at netbsd:Xspllower+0x17: addb %al,0(%eax) 
 db{0} 
Just the luck heh?

The workaround? VBoxSDL.

VBoxSDL is a simple graphical user interface (GUI) that lacks the nice point-and-click support which VirtualBox, our main GUI, provides. VBoxSDL is currently primarily used internally for debugging VirtualBox and therefore not officially supported.

To be able to install NetBSD 5.1.2 on VirtualBox 4.1.14, assuming the virtual machine is name "NetBSD", you'll have to use VBoxSDL like this:
  1. $ VBoxSDL --norawr0 --startvm NetBSD

Now you'll be able to install NetBSD without any issues.

The problem is when you, in your sweet innocence, reboot the system and VirtualBox isn't able to start the vm stating that:
 Failed to open a session for the virtual machine NetBSD. 
 The virtual machine 'NetBSD' has terminated unexpectedly during startup because of signal 11. 
 Details 
 Result Code: NS_ERROR_FAILURE (0x80004005) 
 Component: Machine 
 Interface: IMachine {5eaa9319-62fc-4b0a-843c-0cb1940f8a91} 

The workaround? Yes you've guessed... VBoxSDL:
  1. $ VBoxSDL --nopatm --startvm NetBSD

Peace at last. I can finally muck around NetBSD :D

For reference:
 --[no]rawr0 Enable or disable raw ring 3 
 --[no]patm Enable or disable PATM 
Sources:
http://download.virtualbox.org/virtualbox/UserManual.pdf
http://chvnx.com/post/18341637412/netbsd-in-virtualbox
VBoxSDL --help

Saturday, May 12, 2012

Tip: Merge PDF files into a single PDF using Pdftk

In a previous post I've explained how to extract pages from a PDF document.

Funny enough a few days latter I needed to merge some PDF files into a single document, instead of hunting the web for a Windows application to do that (I have to use Windows at work) I used scp to send the files to the home server, ran pdftk there and scp the merged PDF back ;)

So today I'll use Pdftk this time to merge several PDF documents into a single PDF.

Start by installing Pdftk if you haven't using your distributions package manager:
  • Instructions for installing Pdftk for FreeBSD can be found here
  • If you are using a Debian based distribution issue apt-get install pdftk.
  • Users of RPM distribution's such as RHEL, CentOS, Scientific Linux and Fedora can install it by running yum install pdftk.
  • To install the program on Gentoo use emerge pdftk.
Now onto using Pdftk for our purpose!

The steps to merge PDF documents into a single PDF consist of:

  1. $ cd change_to_directory_with_target_pdfs
  2. $ pdftk first.pdf second.pdf third.pdf cat output merged-pdf.pdf

The PDF should be listed in the order in which they are to be placed in the final document. More information on Pdftk can be found using man pdftk.

Monday, May 7, 2012

Tip: Split selected pages from PDF document using Pdftk

Pdftk is a simple tool for manipulating PDF documents that runs in FreeBSD, Linux, Mac OS X, Solaris and Windows. With it the user can merge PDF documents, repair corrupted PDF, rotate PDF pages or document and extract selected pages from a PDF document creating a new document among other features.

BSD Magazine is a great and free magazine that deals with a wide range of BSD related subjects. The latest issue had a particular article that I felt I wanted to keep close to me.

Using Pdftk I was able to extract the pages that composed the article and keep it in a new PDF document.

Installing Pdftk on FreeBSD is a matter of changing to the print/pdftk port and issuing make install clean, like so:

  1. $ su
  2. # cd /usr/ports/print/pdftk
  3. # make install clean

Make sure to build lang/gcc46 with the JAVA Enable the Java frontend (i386 and amd64 only) OPTION selected or else the build process will fail (take it from me I learned it the hard way).

If you prefer to use packages instead of the ports tree, issue the following commands instead:

  1. $ su
  2. # pkg_add -r pdftk

Now for the fun part: using Pdftk on the this months' BSD Magazine as an example. Start by downloading BSD Magazine 5/2012 issue which you can find here.

I wanted to extract the Hardening FreeBSD with TrustedBSD and Mandatory Access Controls article which runs from page 46 to 49, this how to do it using Pdftk:
  1. $ pdftk 'BSD_05_2012.pdf' cat 46-49 output 'Hardening-FreeBSD-with-TrustedBSD-and-MAC.pdf'

You can find plenty of other uses for Pdftk in applications man page:
  1. $ man pdftk

Saturday, May 5, 2012

Tip: Disable Compiz hot corner

Did you ever reached for the window close and have Compiz display all open windows? Well to me it happened one time too many until I decided I wanted to disable that "feature".

The culprit is the Compiz's scale plugin and the initiate_edge option which initiates Compiz's Window Picker.

However there a couple of ways of disabling the hot corner or assigning another corner than the default top right corner:
  1. Issue the appropriate gconftool-2 command
  2. Install and run gconf-editor
  3. Or install and use ccsm
As methods 2 and 3 imply installing further packages or even enabling a new repository (method 3), I'll explain how to use gconftool-2 to achieve our goal.

To disable the hot corner:
  1. $ gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge Disabled

If you like to hot corner "feature" and would like to move it to the top left corner:
  1. $ gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge TopLeft

To change the hot corner to the bottom left corner:

  1. $ gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge BottomLeft

You can also change the hot corner to the bottom right corner:

  1. $ gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge BottomRight

To re-enable the default hot corner to the top right corner:
  1. $ gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge TopRight

This procedure was executed under CentOS 6.2 thus being applicable to Scientific Linux and RHEL however it can also applied to other Unix-like distributions.

Wednesday, May 2, 2012

Tip: Fix nmap "Error compiling our pcap filter: icmp7 not supported" on FreeBSD

I was going to start Nmap 5.61TEST5 on FreeBSD when it bricked with the following error:
 Starting Nmap 5.61TEST5 ( http://nmap.org ) at 2012-05-02 15:17 WEST  
 Error compiling our pcap filter: icmp6 not supported  
Found that weird because last time I used security/nmap it worked fine but then again that was something like 3 years ago and the port and the application have been updated since. This lead me to think that most likely an OPTION had been introduced to the port:

  1. # cd /usr/ports/security/nmap
  2. # make config===> No options to configure

While investigating the issue I came across problem report ports/159376: security/nmap 5.59BETA1 not working which described the cause of the problem: since NMAP 5.59BETA1 that there was no option to build the port without IPv6 support.

I was pretty sure I've disabled IPv6 and I confirmed that:

  1. # grep INET6 /etc/src.confWITHOUT_INET6=YES

Fortunately since NMAP 5.61TEST2 a patch was added that introduced a workaround for systems build with WITHOUT_INET6 by using net/libpcap.

This is also documented under /usr/ports/security/nmap/Makefile:
 # XXX: Workaround if OS is build with WITHOUT_INET6  
 # PR: ports/159376  
 #  
 # Note: If this option is specified in src.conf it has to  
 # be defined as param -DWITHOUT_INET6 during build time  
 # since the port system has no access to src.conf  
 .if defined(WITHOUT_INET6)  
 LIB_DEPENDS+= pcap.1:${PORTSDIR}/net/libpcap  
 CONFIGURE_ARGS+= --with-libpcap=${LOCALBASE}  
 .endif
The -DWITHOUT_INET6 option needs to be passed to make while building the port, like so:

  1. # make deinstall clean
  2. # make -DWITHOUT_INET6 install clean

Nothing like well documented problem reports and Makefiles ;)