Ubuntu Linux on IBM x40

I installed Ubuntu 5.10 (Breezy) with ease and contrary to Debian (which I ran previously) most of the features of the laptop worked out of the box:

What did not work:

What I din't try:

After going through the install procedure it was mostly about installing all the appropriate packages. With a few exceptions that I'll go through bellow. To get everything else up and flying I got considerable help from the IBM ThinkWiki.

Thinkpad buttons
While the ibm-acpi driver (bellow) enables control of most ibm-buttons and hardware it doesn't feature a nice X interface for the volume control and mute. Install it and remember to enable it in "/etc/default/tpb" and to add your user to the "nvram" group.

  apt-get install tpb
  sudo adduser leopold nvram
Set START_TPB in "/etc/default/tpb" to true != "true".
Add nvram to "/etc/modules" (tpb is started on X login, every now and then it failed for me since /dev/nvram did not exist at this time. I'm supposing modprobe didn't make the device show up quick enough or something).

ALSA sound setup (dmix)
It seems that versions of ALSA prior to 1.0.9rc2 have to be configured to allow two applications to access the sound device simultaneously. In short this involves creating a proper /etc/asound.conf file - see this thread

Later versions of alsa has this setup enabled by default, however newer version is not included in Ubtuntu Breezy. I won't go into the details

hdparm
I'm not really sure how much of a difference it makes but I enabled a few parameters in "/etc/hdparm.conf", to get the best performance:

/dev/hda {
        dma = on
        mult_sect_io = 16
	spindown_time = 240
}

Beep in console mode and X11
To stop the beeping in console mode, edit /etc/inputrc:

 set bell-style none

I couldn't find a config option to stop the bloddy beeping in X11. Some time during login you have to run the "xset" command. If you're using a custom .xsession that would be a perfect place. I'm using the standard XFCE4 login and run the command during login I created the following file "root@ratata:/etc/X11/Xsession.d/91xset" containing the command:
  xset b off

Use X11 blanking instead of XFCE4
It seems that mplayer is unable to disable the blanker in XFCE4, however mplayer can disable the built-in blank i x.org (and XF86 for that matter). The blank-times can be set with xorg.conf or with the xset command. I used the xsession script above (91xset) to tune my blank times.

I'm not sure what the three power modes (standby, suspend, off) means with an LCD panel, but you can specify each in seconds:

  xset s blank # set preference to bblank the video (if the hardware can do
               # so) rather than display a background pattern
  xset dpms 200 201 600 #standby suspend off (in seconds)

Automatic login
I want my laptop to login as my personal user automatically. This is accomplished by tuning /etc/gdm.conf. Look for the following:

  AutomatedLoginEnable=true
  AutomatedLogin=leopold

Set paper size
Set the paper size to a4 in the following file

   /etc/papersize

Set display right after resume
To make sure that the display is right after resume enable a small hack in /etc/default/acpi-support (this is particularly important on the x40 or your screen might be garbled after resume):

  DOUBLE_CONSOLE_SWITCH=true

Network setup
To detect and configure ethernet (wired) when it is inserted install ifplugd and configure it with /etc/default/ifplugd. Remove the line "map eth0" from /etc/network/interfaces to allow ifplugd to configure the network instead of hotplug (hotplug stalls during boot if it cannot get a DHCP-assigned address).

It seems that ifplugd stops every on suspend/resume (maybe the network driver is removed causing ifplugd to crash?). To solve this add ifplugd to the list of programs to stop/start when suspending/resuming in "/etc/default/acpi-support":

   STOP_SERVICES="mysql ifplugd "

Wireless
In order to support WPA encryption the "WPA supplicant" daemon is required. The package unfortunately automatically install all of its dependencies - remember to install opensc as well. Netapplet provides a small system tray applet for monitoring and selecting networks and integrates perfectly with XFCE4.

apt-get install opensc wpasupplicant netapplet

External VGA

The external VGA port has to be enabled before it is operational. Luckily Ubuntu provídes packages for two quick-and-dirty utils to simply duplicate the content of the LCD screen: i855-crt and i810switch. I looked at a few other options that I'll describe bellow.

The graphics chip in my laptop is Intel 855GM based or "Extreme Graphics 2" - the IBM ThinkWiki has more

i810switch and i855-crt
To the best of my knowledge both are quite similar and duplicates the LCD screen onto the VGA port. Both have Ubuntu packages. i810-switch mentions that should you experience any problems with an i855 chip you should try i855-crt. i855-crt has a configuration file specifying possible display modes of the external monitor - it is unclear to me how i810switch determines the resolution.

i855-crt can be used like this:

  sudo apt-get install i855-crt
  i855crt on "1024x768@75"

ibm-acpi
The ibm-acip module allows switching the external VGA port on and of using a simple file-interface:

  echo "crt_enable" > /proc/acpi/ibm/video
However this resulted in a garbled screen when I tried it (using xorg with the i810 driver, version 6.8.2).

Dual-head
An appealing alternative to simply duplicating the screen content could be to setup the external VGA port as a separate screen (similar to dual head). I din't try this but this guy did on his x40.

Applications

I use the "cholesterol free desktop environment" XFCE4, I need a compiler and flash for my browser, and a lot of more stuff. For me the following gave most of what I need:

Apt sources
I choose the mirror closest to me and enabled the multiverse and universe distro's in /etc/sources.list:

   deb http://dk.archive.ubuntu.com/ubuntu breezy main restricted universe multiverse
   deb-src http://dk.archive.ubuntu.com/ubuntu breezy main restricted
Furthermore I wanted a few packages versions that are not in breezy:
   deb http://dk.archive.ubuntu.com/ubuntu dapper main restricted universe multiverse
   deb-src http://dk.archive.ubuntu.com/ubuntu dapper main restricted
Setting the default distribution is done in /etc/apt/apt.conf
   APT::Default-Release "breezy";

Laptop related

laptop-mode laptop-mode-tools ifplugd 

Build Environment

sudo apt-get install build-essential gcc-avr binutils-avr uisp cvs
subversion subversion-tools manpages-dev autoconf automake libtool
flex bison make perl perl-doc gbase

Media and Internet Stuff

apt-get install mozilla-firefox flashplugin-nonfree mplayer-586
 mozilla-mplayer evolution xmms gaim lynx w3m gxine pan airsnort
 aircrack kismet wavemon tcpdump jhead netapplet ncftp

w32codecs
The Ubuntu starter guide suggests getting the Debian packages, but this guy has compiled a package for ubuntu, stuff the following into /etc/apt/sources.list and your ready to go.

 deb ftp://cipherfunk.org/pub/packages/ubuntu breezy main
 sudo apt-get install w32codecs libdvdcss2

Office-ish

 jed emacs21 w3m idanish aspell-da wdanish openoffice.org2-l10n-da
spell myspell-da gqview xfig sketch inkscape sodipodi imagemagick dia
perlmagick pstoedit acroread mozilla-acroread msttcorefonts auctex
tetex-extra tetex-doc tetex-base xpdf psutils a2ps gv pstoedit lyx
numlockx

dictionaries-common
The flyspell mode in Breezy has a bug that makes emacs complain "Can't check region" whenever you try to spell check with flyspell-region. To fix that get a newer version of the package dictionaries-common like this:

sudo apt-get install dictionaries-common=0.62.5ubuntu2

Opera
Get opera from www.opera.com and install:

sudo dpkg -i opera_8.51-20051114.6-shared-qt_en_etch_i386.deb

Firefox Crash Recovery Extension
To allow firefox to recover your open windows after a crash get Crash Recovery.

Java
Java is installed via the package "java-package". First download the JRE or JDK from Sun and this will transform the binary into a .deb package.

sudo apt-get install java-package
fakeroot make-jpkg jdk-1_5_0_06-linux-i586.bin

ACPI setup (buttons and more)

Suspend on low battery
To me the most sensible thing to do when the battery is close to depletion is to hibernate the laptop. The battery issues ACPI regularly as it discharges - we can use these to suspend when we are close. We want the laptop to suspend on the last event and simply suspend to disk.

I created a simple script that does exactly this: /etc/acpi/actions/battery-low-hibernate.sh, download the script and the event description enable it:

   wget http://www.leopold.dk/~martin/patches/battery-low-hibernate.sh
   sudo mv battery-low-hibernate.sh /etc/acpi/actions/
   wget http://www.leopold.dk/~martin/patches/battery-low-hibernate
   sudo mv battery-low-hibernate /etc/acpi/events

Disable lock screen on lid close
On lid close the script "/etc/acpi/lid.sh" is fired, which locks and blanks the screen using dpms. For me blanking is enough so comment out the following line:

    su $user -c "(xscreensaver-command -throttle; xscreensaver-command -lock)"

Kill Radio on Key Press
The wireless.sh script provided by Ubuntu (and activated by the wireless button) only kills the Bluetooth radio - not the WiFi. This would be practical say on a plane.

The script radio.sh will disable both Bluetooth and Wireless if any of them is enabled and enable both otherwise. Disable the Ubuntu script and enable this one with an event description:

   sudo mv /etc/acpi/events/ibm-wireless /etc/acpi/events/
   wget http://www.leopold.dk/~martin/patches/radio.sh
   sudo mv radio.sh /etc/acpi/actions
   wget http://www.leopold.dk/~martin/patches/radio
   sudo mv radio /etc/acpi/events/

Custom kernel

For a number of reasons I want to compile my own kernel:

Kernel
Ubuntu uses the Debian kernel build system that compiles the kernel into a handy .deb package. You can configure the kernel before or during the process as you like. I did a little bit of both, but what I need to configure is:

Furthermore I would like to apply a patch (see bellow)
  apt-get install linux-source-2.6.12
  wget http://fabrice.bellamy.club.fr/bdz.undervolt.2006.01.07.patch
  tar jxfv linux-source-2.6.12.tar.bz2 
  cd linux-source-2.6.12
  patch -p1 < ../bdz.undervolt.2006.01.07.patch
Now compiling and configuring is a breeze:
  fakeroot make-kpkg --config=menuconfig --initrd --append-to-version -ml --revision 1 kernel-image

ipw2200 and ieee80211
To get ipw2200 up and running you need both the driver and firmware from ipw2200.sf.net and you need the ieee80211 from ieee80211 . Compile the two source packages and unpack the firmware to "/lib/hotplug/firmware/" and you should be ready to go.

ibm-acpi
This driver enables some the extra features of the laptop such as ACPI events for the IBM buttons, thermal reading, etc. Version 0.11 of the driver support for fan control. Unfortunately there is a name clash with one of the functions in ibm-acpi and the kernel - so I renamed one of the functions and made a patch:

  wget http://www.leopold.dk/~martin/patches/ibm-acpi-0.11-kernel-2.6.12.patch
  cd ibm-acpi-0.11
  patch -p1 < ../ibm-acpi-0.11-kernel-2.6.12.patch
  make
  sudo make install

Undervolting

Lowering the voltage of the CPU (undervolting) has a clear impact on the power consumption of the chip. How much is varies from model to model and even from chip to chip. The current 2.6 series of kernels does not allow fiddling with the core voltage and requires the kernel to be patched (see above).

Thinkwiki has a thorough article going through the details specifically for IBM laptops and gives an overview of 3 different patches. The gentoo-wiki has an article giving more in depth information about the patch that I choose.

Controlling voltages with the "Bdz" patch
The patch above allows fine grained control of the voltage using a simple interface. It allows voltage in the range 7-16 V and will reject voltages out of this range. I took the suggestion from thinkwiki and applied like so:

   sudo echo "1116,1116,1100,1068,972,876,780,700" >\
       /sys/devices/system/cpu/cpu0/cpufreq/voltage_table

Results
I didn't do a thorough test but looking at the discharge rate from the battery for a few minutes, I saw a drop of about 1 W (~8 %).

Copyright © 2006 Martin Leopold Created on January 21, 2006
Last modification on August 9, 2006