Installing Gentoo on a ThinkPad R40

From ThinkWiki
Jump to: navigation, search

This article has been taken from Brian Jensens homepage about Gentoo Linux on an IBM R40
Minor additions and edits by Jinxos


I've just recently made the switch from Gentoo to SuSE and am quite happy. I've been using SuSE for about a year now, and actually i was pretty satisfied with SuSE. Until I broke my Distro(I don't remember exactly what app i was trying to install but i managed to overwrite my gtk libs with incompatible versions, yes rpm is cool like that...) things were working pretty smoothly, the only real big problem i had was with their powernowd. I figured since my system was broken anyways, I might as well try my hand at a more elite linux distro(no offense, SuSE is a pretty good distro, but designed for n00bz, which made getting help in forums, customizing config files,.. a real pain in the ass). I was opting for debian, but gentoo's self building all packages caught my eye so i had to try it out for real.

I've decided to write my experiences with gentoo here in the beginning because its been some time since i started writing this document and now i have some things i think i should comment on. First, the gentoo package management system portage is in my opinion far better and easier than using rpm, all you have to do is type in the name of the package and it downloads and installs it for you. No more downloading/searching for a butt load of rpms and their dependencies. However this system isn't perfect, because I use the newest version of gcc and newest file system Reiser4, i've had some minor problems. I cannot install Open Office Ximian edition(Reiser4 problem), and Open Office (problem with the build script and gcc3.4). I also haven't gotten mplayer to properly function due to unknown reasons. But for the most part my system is pretty stable, I haven't had a complete system crash yet despite using direct rendering and Software suspend 2. Acually I haven't even had the X server crash on me once. I do however warn against using 2.6.11 kernels, I have had nothing but problems with them.

My System Specs

Machine: IBM Thinkpad R40 2272-BDG

  • Pentium M 1.4 Ghz
  • 512 MB DDR SDRAM
  • 40GB 4200 Fujitsu HDD
  • 15.0 XGA (1024x768) TFT LCD
  • 32MB DDR ATI Radeon Mobility M7 LW
  • Matshita 24/10/34/8x CD-RW / DVD
  • Intel Pro Wireless 802.11b WiFi MiniPCI card
  • Intel Pro 10/100 Ethernet

output from lspci:

bash-2.05b# lspci
0000:00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 03) 
0000:00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 03) 
0000:00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 01) 
0000:00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 01) 
0000:00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 01) 
0000:00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCIController (rev 01) 
0000:00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 81) 
0000:00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 01) 
0000:00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 01) 
0000:00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 01) 
0000:00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01) 
0000:00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 01) 
0000:01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility M7 LW[Radeon Mobility 7500] 
0000:02:00.0 CardBus bridge: Texas Instruments PCI1510 PC card Cardbus Controller 
0000:02:02.0 Network controller: Intel Corporation PRO/Wireless LAN 2100 3B Mini PCI Adapter (rev 04) 
0000:02:07.0 FireWire (IEEE 1394): Texas Instruments TSB43AB21 IEEE-1394a-2000 Controller (PHY/Link) 
0000:02:08.0 Ethernet controller: Intel Corporation 82801DB PRO/100 VE (MOB) Ethernet Controller (rev 81)

Preparing the Install

SuSE 9.1 already shipped with ReiserFS v3 and i was very happy with the performance, so i opted with the new install to reformat and give Reiser4 a whirl, which is supposed to be more space efficient and quicker than any other FS. In order to install gentoo with Reiser4 as the root file system, you have to use the Reiser4 LiveCD from lxnay. But you also have to create an extra boot partition, as Grub and lilo both cannot boot from Reiser4. My partition table is as follows:

  • /dev/hda1 11GB The shrunken default XP NTFS partition
  • /dev/hda2 14GB FAT32 partition to share files between XP and linux
  • /dev/hda3 32MB ext2 /boot partition
  • /dev/hda4 Linux extended partition
  • /dev/hda5 560 MB swap space, also used by Software Suspend 2
  • /dev/hda6 8.5 GB Reiser4 / partition

If you haven't yet installed linux your machine, you can find out here how to cleanly shrink your NTFS partition. If you plan on just killing your NTFS partition you might as well kill the 5 GB pre desktop area partition hidden on the disk by going into BIOS Setup and turning the partition off, allowing you to easily overwrite the data there(else fdisk and many other partitioning tools will give you weird errors).


I'm not going to cover every step of the installation, the gentoo install docs are very well prepared and easy to follow. Im only going to go over the things i think are important and not covered and there were a few thing that weren't covered.

First things first, assuming you already partitioned your harddisk correctly, setup portage, unpacked the stage 1 tarball and correctly and chrooted into the install environment (There's really not much that can go wrong up till now) there are a few options you have to configure before bootstraping. At the top of the list is to configure /etc/portage/package.keywords so that we can bootstrap to gcc 3.4.x(This version of gcc has special optimizations for the pentium m :-) ). For that we do a quick:

bash-2.05b$ echo -e 'sys-kernel/linux26-headers ~x86 \nsys-libs/glibc ~x86
\nsys-devel/gcc ~x86 \nsys-libs/libstdc++-v3 ~x86' >> /etc/portage/package.keywords

Note: For the moment being your CFLAGS are pretty much unimportant, because once we build gcc, glibc, and gcc-config we're going to rebuild them using optimizations that only gcc 3.4.x has. Before we start however, i highly recommend that you add the following two options to your USE flag: nptl nptlonly. These options specify that you will compile gcc and glibc, and thus all programs with the Next Generation Posix Threading Library and without native linux threading support(believe me, you won't regret it). The option nptlonly is very important for a number of reasons, foremost being that without you will end up building 2 versions of glibc and gcc(which once bootstrapped you'll understand why you this is a very annoying thing), and because without it you'll get errors building the base system as the programs will improperly choose which threading version to build for (arghh libperl ...).

Now assuming that you set those 2 options in your use flag, go ahead and run the /portage/scripts/ , go and get yourself something and put the LOTR Return of the King DVD in, cause its going to be a LONG time. Once bootrap has done its job, enter the following command:

bash-2.05b# gcc-config -l 
[1] i386-pc-linux-gnu-3.3.4 
[2] i686-pc-linux-gnu-3.4.3-20050110 * 
[3] i686-pc-linux-gnu-3.4.3-20050110-hardened 
[4] i686-pc-linux-gnu-3.4.3-20050110-hardenednopie 
[5] i686-pc-linux-gnu-3.4.3-20050110-hardenednossp

Your output will probly look different than mine, but if you don't have an entry 3.4.x-y, then something must have been wrong in your /etc/portage/package.keywords file, so double check that it contains all 3 entries from earlier and rebootrap. Ok now you want to set 3.4.x-y as the default compiler by selecting it using gcc-config:

bash-2.05b# gcc-config 2 
* Switching to i686-pc-linux-gnu-3.4.3-20050110 compiler...            [ ok ]

You should also check to make sure that your newly compiled glibc has Posix threading support enabled and not with linux threading. To do that just check for POSIX threads from the following command:

bash-2.05b# /lib/ 
GNU C Library stable release version 2.3.4, by Roland McGrath et al. 
Copyright (C) 2004 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 
Compiled by GNU CC version 3.4.3-20050110 (Gentoo Linux, ssp-, pie-8.7.7). 
Compiled on a Linux 2.6.8 system on 2005-02-18. 
Available extensions: 
    GNU libio by Per Bothner 
    crypt add-on version 2.1 by Michael Glad and others 
    Native POSIX Threads Library by Ulrich Drepper et al 
    BIND-8.2.3-T5B NIS(YP)/
    NIS+ NSS modules 0.19 by Thorsten Kukuk 
Thread-local storage support included. For bug reporting instructions, please see:

Alright now you're ready to really build the system using complete current optimizations. On my machine I use highly specific optimizations for the pentium-m (banias core) that i hand picked using the test results from Acovea. Acovea is very powerful tool to evaluate compiler optimizations and their performance on different hardware platforms. On my machine the fastest code is achieved by using the following optimizations: CFLAGS="-march=pentium-m -pipe -fomit-frame-pointer -fno-delayed-branch -fcaller-saves -freorder-blocks -freorder-functions -falign-jumps -finline-functions -frename-registers -fweb -fno-trapping-math -ffast-math -falign-functions=64". Don't forget to set: CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden". Rebootstrap the system with the new compiler options and take another break. If you are interested in what these individual optimization flags do, have a look at the gcc optimizations page.

Once you've succesfully bootsrapped again, its time to run 'emerge system' and go find another time killer, although this step shouldn't take as long as bootstrapping. If for some reason a package should fail to emerge due to loading errors(ld: undefinded symbol ...) then take '-fvisibility-inlines-hidden' out of your CXXFLAGS and emerge that particular package again(this happened to me with a couple of different packages), then put it back in again and continue to emerge the system. If you get generel compilation failures, then try using less aggressive CFLAGS like 'm-arch=pentium-m -pipe -O2' for the individual packages(I have not had this problem as of yet) and then continue building your system with normal flags. Kernel

There's not all too much to be said about this step. Because the default 2.6.10 kernel doesn't currently support Reiser4 i decided to go with the nitro sources, which are pretty much 2.6.x kernels with patches for Reiser4, vesa-fbtng, fbsplash, Software Suspend 2, and a couple of other things. You can follow the guide in the link to first setup a portage overlay, and then install the nitro sources. If you don't like the nitro sources for some reason you could also try the love sources as they support everything your need. You can download my .config file here, or if your not using an R40 but an IBM laptop, there are a few options i recommend turning on in the kernel.

To be able to continue using your volume buttons you need to have Device Drivers/charachter devives/nvram enabled in the kernel. To be able to use your Fn-key combinations (assuming you will also be using acpi) you need to turn on Power Management options/ACPI/IBM Thinkpad extras. To enable Reiser4 support under File Systems you have to turn off Kernel Hacking/use 4k stacks instead of 8k. Also if you want to use direct rendering with X(Direct Rendering is needed to enable 3D support with your graphics chip), don't forget to turn it on in the kernel under Device Drivers/ Character devices (and on a side note, under agpart you have to select your northbridge chip, on my R40 an Intel i8xx, and under Direct Rendering Manager you select your graphics chip, so for me this ati radeon). If you want to use Software Suspend 2 then you have to enable it under Power Management Options / Software Suspend 2 along with Swap writer, LFZ compression, text mode console support. You also have to enter your swap partition under Default resume device name.

For bootsplash support make sure to turn on the following options in the kernel:

Device Drivers ---> 
  Graphics support --->
    [*] Support for frame buffer devices
      <*>   VESA VGA graphics support
        VESA driver type (vesafb-tng) --->
         (1280x1024@60) VESA default mode
        [*]   Support for the framebuffer splash
    Console display driver support --->
      [*]    Video mode selection support
      <*>   Framebuffer Console support 
Device Drivers --->
 Block devices --->
    <*> RAM disk support
      (4096) Default RAM disk size (kbytes)
      [*] Initial RAM disk (initrd) support

To compile and install the kernel refer to the gentoo install guide

Installing the wlan driver (ipw2100)

This actually is a pretty trivial step, once you know which driver method you want to use. To date there exists 2 methods to use the ipw2100(the default centrino wireless chip), either with your windows drivers and ndiswrapper or with the open source drivers from intel. I use the open source drivers from intel, mostly because ndiswrapper doesn't support various card options(promiscuous mode etc ...). If you want to use ndiswrapper instead, i used to when i had SuSE installed, i can report that it works and that the install is fairly easy, just refer to the install docs on their homepage.

When using the open source drivers on gentoo you have 2 ways to compile them. Either you run an emerge ipw2100 (After you've already built and installed your kernel), or you download the sources yourself from their website and merge them into the kernel source tree. I opted for the latter of the two, as i rebuild my kernel quite often and i find its just more convient to have the ipw2100 rebuilt with it each time. If your going to use my .config or know exactly what you need/want in your kernel and aren't planning on rebuilding it often, then running an emerge ipw2100 is probibly best for you.

To merge the driver into the source tree, assuming you already downloaded the driver and unpacked the firmware images to /etc/hotplug/, you have to extract all the files from the source tarball to /usr/src/linux/drivers/net/wireless/ipw2100. Then you have to switch the directory to /usr/src/linux and run the following command to patch the kernel make files:

bash-2.05b brian# cd /usr/src/linux
bash-2.05b linux# patch -p1 < drivers/net/wireless/ipw2100/patches/ipw2100-2.6.10-patch
patching file Documentation/networking/README.ipw2100
patching file drivers/net/wireless/Kconfig
patching file drivers/net/wireless/Makefile

If all went well and no error messages were given, then you can now turn on the ipw2100 in kernel under Device Drivers / networking / wireless / generic 802.11 networking stack. I recommed compliling as a modules, if the driver crashes for any reason, you can remove it and reinsert it into the kernel, or if you want to be able to turn the wireless connection off you need to have the driver compiled as a module.Now you should recompile and resinstall the kernel. All you have to do to finish up is to do an emerge wirelesstools if you haven't already, and if you compiled as a module, then you need to add an entry ipw2100 to /etc/modules.autoload.d/kernel-2.6 and run:

bash-2.05b linux# modules-update

Configuring Xorg

Alright so if you've made it to this step, im assuming you already configured and installed the gentoo base system and you're running on your own kernel and no longer from the live cd. There isn't much that needs to be done, gentoo does a good job and configuring your hardware. On my machine gentoo automatically installed the correct graphics driver, and the default config wasn't too bad either, but if you want to be able to play 3d games like Neverball or Tux Racer, you will need to enable direct rendering. I'm also assuming that you have direct rendering in the kernel enabled and the prorper driver picked(If not refer to the kernel section for selection criteria).

All you really need to do is enable direct rendering your /etc/X11/xorg.conf file. To do this you need to make changes on 3 different parts of it, first and foremost under section module make sure you have dri, glx, and freetype. Here's how my modules section looks:

Section "Module"
       Load "dbe"
       Load "dri"
       SubSection "extmod"
         Option  "omit xfree86-dga"
       Load "extmod"
       Load "glx"
       Load "record"
       Load "xtrap"
       Load "freetype"
       Load "type1"

Next you need to set the agp mode for the radeon, i currently use 4x mode. I also recommend turning on AGP Page flipping.

Section "Device"
        Identifier "radeon"
        Driver "ati"
        VendorName "ATI Technologies Inc"
        BoardName "Radeon Mobility M7 LW [Radeon Mobility 7500]"
        BusID "AGP:1:0:0"
        Option "AGPMode" "4"
        Option "EnablePageFlip" "True"

And the last and optional step is too make sure that normal users can use direct rendering, to do that just copy the following lines into your config file if they aren't already in there. Note: direct rendering will still work without this, but it will only be available for users with root priveledges.

Section "dri"
        Mode 0666

If you have an additional wheel mouse, like i do, and wan't to be able to use the scrolling wheel all you have to do is add Option "ZAxisMapping" "4 5" under the input device section.

Section "InputDevice"
        Identifier "Mouse0"
        Driver "mouse"
        Option "Protocol" "Auto"
        Option "Device" "/dev/mouse"
        Option "ZAxisMapping" "4 5"

Since the R40 comes with both a Synaptics touchpad and TrackPoint you can modify your setup to use both:

Section "ServerLayout"
   Identifier	"Single Monitor w/ VGA Enabled"
   Screen	"Screen0" 0 0
   InputDevice	"Keyboard0" "CoreKeyboard"
   InputDevice	"Touchpad"  "CorePointer"
   InputDevice	"TrackPoint""SendCoreEvents"

with the Touchpad being controlled by the synaptics driver (you did emerge synaptics right?)

Section	"InputDevice"
  Driver  "synaptics"
   Identifier	"Touchpad"
   Option  "Device"	"/dev/input/mouse0"
   Option  "Protocol"	"auto-dev"
   Option  "LeftEdge"	"1700"
   Option  "RightEdge"	"5400"
   Option  "BottomEdge"    "4200"
   Option  "TopEdge"	"1700"
   Option  "FingerLow"	"25"
   Option  "FingerHigh"    "30"
   Option  "MaxTapTime"    "180"
   Option  "MaxTapMove"    "220"
   Option  "VertScrollDelta"	"100"
   Option  "MinSpeed"	"0.06"
   Option  "MaxSpeed"	"0.12"
   Option  "AccelFactor"   "0.0010"
   Option  "SHMConfig"	"on"
   Option  "CircScrollTrigger"	"3"
   Option  "CircularScrolling"	"1"
   Option  "UpDownScrolling"	"off"

while the TrackPoint is handled by the standard PS/2 mouse driver (in the kernel, if enabled)

Section "InputDevice"
  Identifier  "TrackPoint"
  Driver  "mouse"
  Option  "Protocol" "PS/2"
  Option  "Device" "/dev/mouse"
  Option  "EmulateWheel" "on"
  Option  "EmulateWheelButton" "2"
  Option  "YAxisMapping" "4 5"
  Option  "SendCoreEvents"    "1"

note how that for the trackpoint the Y axis is mapped to act like a wheel. I find this very handy.

Remapping the keyboard

Having spent some time looking around for an XKB keyboard map for the R40 keyboard i must say i find it very disappointing that one does not yet exist (Jinxos says: of course i COULD be wrong, please let me now). Anyway, i opted for the quick solution of using Xmodmap (please note that this is a Greek keyboard, not that it changes much but...) so my Keyboard section is:

Section "InputDevice"
  Identifier  "Keyboard0"
  Driver	"kbd"
  Option	"XkbModel"  "pc104"
  Option	"XkbLayout" "us,el"
  Option	"XKbOptions"	"grp:alt_shift_toggle"
  Option	"XkbVariant"	",extended"

and my Xmodmap:

keycode 0x31 =	backslash	bar		onehalf		plusminus
keycode 0x30 =	asciicircum	asciitilde
keycode 0x33 =	grave		at
keycode 0x0A =	1		exclam
keycode 0x0B =	2		quotedbl
keycode 0x0C =	3		numbersign
keycode 0x0D =	4		dollar
keycode 0x0E =	5		percent
keycode 0x0F =	6		ampersand	
keycode 0x10 =	7		slash
keycode 0x11 =	8		parenleft
keycode 0x12 =	9		parenright
keycode 0x13 =	0		equal
keycode 0x14 =	apostrophe	question
keycode 0x15 =	plus		asterisk
keycode 0x22 =	bracketleft	braceleft
keycode 0x23 =	bracketright	braceright
keycode 0x5E =	less		greater
keycode 0x3B =	comma		semicolon
keycode 0x3C =	period		colon
keycode 0x3D =	minus		underscore
keycode 0x4D =	Scroll_Lock	Num_Lock
keycode 234 = F19
keycode 233 = F20

Note the last two which are the two grey buttons above the Right and Left arrow keys. This way I use them to switch desktops in WindowMaker.

Setting up ACPI

On a mobile machine power management is a very important feature of any OS. Under linux there are currently two choices for power management, APM and ACPI. APM is older and not as efficient, it leaves all the power management settings up to BIOS, and is not very configurable. But therefore its supposed to be more stable than ACPI. ACPI is the new power management approach, where the OS handles all the settings itself like CPU frequency stepping, suspending(also known as S3 sleep) and hibernating(also known as S5 sleep). I use ACPI and find that i get much better performance/battery life with ACPI(Using APM 3.5 hours, under ACPI 4.5-5, thats a big difference).

Setting up ACPI is a two part process, first you have to enable ACPI support in kernel(and if you want to be able to use the Fn key combinantions you also need to turn on IBM ACPI Extras), then you have to install the acpid daemon. For kernel configuration settings see the Kernel section.

To begin you have to run emerge acpid.Then you need to add acpid to the default runlevel with rc-update add acpid default. Configuring acpid is actually very easy, all you have to do is set up a series of events with actions for each one of the events. When acpid loads, it loads all the files located in /etc/acpi/events/ that don't begin with a '.', so when editing your config files make sure that your editor doesn't leave backup copies with a ~ extension, cause they will get loaded as well by acpid, which causes events to get processed twice and that is no fun(guess what that does.. ). Each config has the form: event=Regular Expression action=System command or script To make things simple, I'm just going to post my acpid config files. But before i do i suggest removing the default event handler located in /etc/acpi/events/default because you won't be needing it anyways. The first config file is pretty standard, it contains my lid function which puts the laptop into S3 sleep or suspend to ram. Suspend to ram turns power to all output devices and the CPU off, thus leaving only the ram and certain input devices powered on saving a lot of power. I named this file

#This is the config file for the lid, setting laptop in suspend mode 
event=button/lid LID 00000080 0000000. 
action=echo 3 > /proc/acpi/sleep

You notice that my action for the lid event echo 3 /proc/acpi/sleep is the general method used to set the laptop in the sleep state(you can check if ACPI sleep even works by entering echo 3 /proc/acpi/sleep on the command prompt as root). If you have problems with devices not working correctly after you bring the laptop back up, you may need to remove certain modules before going to sleep and then reinsert them back in after restoring. Note: If you notice that the clock runs twice as fast as it should when under S3 sleep, thats most likely because of a bug in 2.6.9 and 2.6.10 kernels specific to the timing hardware in IBM laptops and has not been fixed in the official kernel source tree, I've posted a quick fix for the problem here.

The next couple of ACPI events i have enabled are using the IBM Fn hotkeys, so before setting up the acpid config files you need to first enable the hotkeys and check to make sure they are prorperly handeled by acpid. First check if the IBM ACPI Extras driver is up and running:

bash-2.05b# dmesg | grep ibm 
ibm_acpi: IBM ThinkPad ACPI Extras v0.8 

Your output should look similar to mine, if it didn't you probibly didn't have IBM ACPI Extras compiled in the kernel. Next you need to turn the hotkey functionality on, you do this with echo enable > /proc/acpi/ibm/hotkey. I suggest you always enabling this on boot time, you can do this by adding the following 2 lines to your /etc/conf.d/local.start file:

echo "Turning on IBM ACPI hotkey support..." 
echo "enable" > /proc/acpi/ibm/hotkey

Now give a couple of Fn key combinations, nothing should happen quite yet. You need to check if the Fn hotkey events you just pressed got passed to acpid, if they were acpid will print a statement about it in its log: bash-2.05b# cat /var/log/acpid | grep ibm [Sat Feb 26 13:08:53 2005] received event "ibm/hotkey HKEY 00000080 00001003" [Sat Feb 26 13:09:10 2005] completed event "ibm/hotkey HKEY 00000080 00001003" [Sat Feb 26 13:09:16 2005] received event "ibm/hotkey HKEY 00000080 00005001" [Sat Feb 26 13:09:16 2005] completed event "ibm/hotkey HKEY 00000080 00005001"

If you don't see anything try giving a couple more Fn-F3 presses and check the log file. If for some reason you still don't see anything, try restarting acpid:

bash-2.05b# /etc/init.d/acpid restart 
* Stopping acpid...     [ ok ] 
* Starting acpid...     [ ok ]

Setting up the Fn hotkey combinations is pretty similar to setting up the lid event. The hotkey i setup was the Fn-F4 hotkey which puts the laptop into S3 sleep like it does under windows. My file is called

bash-2.05b# cat 
#new script for IBM suspend to ram hotkey(sleep) 

event=ibm/hotkey HKEY 00000080 00001003 
action=echo 3 > /proc/acpi/sleep

The next hotkey event I setup was Fn-F12, suspend to disk or hibernate. I am putting this step here so that once you have completely setup up Software Suspend 2 you can just as easily suspend your machine as under windows. I named this file

bash-2.05b# cat 
#new script for IBM suspend to disk hotkey(hibernate) 

event=ibm/hotkey HKEY 00000080 0000100c 

All you have to do is restart acpid and you should be all set.

I still need to cover Fn-F3(Screen blanking) and Fn-F5(Network on and off), the rest of the hotkeys work automatically because they are implemented in hardware. If you use KDE, you can use the KMilo Plugin to display hotkeys like windows does. For additional information on IBM Hotkeys under linux look here.

Enabling CPU frequency switching

To enable real powersaving on your laptop, you have enable CPU frequency switching. The two most power consuming devices in a mobile computer are the display and the CPU. On the IBM R40 the display can be automatically dimmed or shut off using the Fn hotkeys as their implementation is in Hardware. However gentoo doesn't provide any support for CPU Frequency switching by default. This doesn't mean support for this in gentoo is bad, no the contrary, gentoo provides support for many different mechanisms to dynamically controll the CPU's freq. There are 2 different types of 'CPU Frequency governors' which regulate the frequency, user space and kernel space. User space governors are daemons like acpid or crond that sit and watch the CPU Usage and dynammically change the frequency based on usage, programs open, windom manager etc. The two most comon user space governors are CPUFreq and SpeedFreq, which both offer a long list of features and configuration options. For information on using these see the Gentoo Linux Power Managemnet Guide.

I opted for a kernel space governor for a number of reasons: Its more convienent to use a kernel space governor, its easier to setup, and its more efficient than a user space governor as its built right into the kernel. Current kernel space governors do have some disadvantages: they are not as custimizable(Its very hard to make different settings for watchings DVDs, text editing ...), and they change with each kernel version you use. But I personally find these to be minor disadvantages, I don't need such a complicated power management scheme. Currently there exists only one kernel space governor, you enable it in the kernel under Power Management options/CPU Frequency Scaling/'ondemand' cpufreq policy governor. If you already have this feature built into your kernel or you are not sure, you can check with this: bash-2.05b# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ondemand powersave userspace performance

This lists the available governors available in the running kernel, if you don't see ondemand listed you need to recompile your kernel and reboot. Turning ondemand on is actually very simple, just enter echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor on the command prompt, and now check to see if its working by closing all running apps and polling the cpu freq: bash-2.05b# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 9 model name : Intel(R) Pentium(R) M processor 1400MHz stepping : 5 cpu MHz : 599.738 cache size : 1024 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr mce cx8 sep mtrr pge mca cmov pat clflushdts acpi mmx fxsr sse sse2 tm pbe est tm2 bogomips : 1183.15

Your output should look similar to mine, that being with no apps running your cpu should default to 600 MHZ. Now do an emerge nano(or any other application for that matter) in one terminal and poll the cpu freq in another. This time your cpu MHZ field should be at its maximum, by me 1400 MHZ. If thats the case then CPU frequency is succefully working, now you just need to fine tune it to your wishes and possibly enable it at boot time. To change the CPU usage percent at which ondemand kicks the freq up to maximum, you set the value(in percent) in /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold. To change the procent at which ondemand drops the CPU freq down to the next level, set the value(in procent) in /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold. And of course you probibly want to enable frequency hopping at boot time, do that by adding these 4 lines to /etc/conf.d/local.start: echo "Enabling CPU FREQ governor 'ondemand' in kernel.." echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor echo "60" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_threshold echo "90" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold

There are many more options available to really fine the performance of ondemand, for more information on this topic see this guide by intel.

Configuring Software Suspend 2

For this part I expect that you have Software Suspend 2 support compiled into your kernel(available with both the love and nitro sources) with swap writer support and you correct swap partition selected. I also expect that you have a functional swap partition that is at least as large as your RAM, recommended is the size of your RAM plus about 10% for safety.

To begin you need to run emerge hibernate-script. Once its done all you have left to do is configure how your machine suspends, this is accomplished with the /etc/hibernate/hibernate.conf file. I'll go over the most important options but you can also download my hibernate.conf here.

First set UseSwsup2 to yes. If you compiled software suspend 2 support as a module than uncomment out the line LoadSuspendModules. Set powerdownmethod to 5. Make sure all the items under acpi_sleep and sysfs_power_state are commented out. The last and most important option you have to enable is SwitchToTextMode yes. Without this option suspend won't work, and will crash your system. The option UseDummyServer wasn't necessary on my system for Swsup2 to work. All the rest of the options in hibernate.conf are not so important and are different on every system. The last step is to add the paramter resume2=swap:(Enter your swap partition here) to your /boot/grub/ment.lst.

Now test out Swsup2 by first switching to another virtual tty(for those who forgot how, press ctrl+alt+F1), log in as root and run hibernate. If everything went well while suspending/resuming, switch back to your x session(ctrl+alt+F7) and check to make sure everything still functions. If there was a problem and or your system froze first try it once again, if the same error happens twice, then check the log file /var/log/hibernate.log. When everything worked out, try suspending inside your xsession, and if that works then you're done. If you enabled the IBM hotkeys and set them up properly like I described under Setting up ACPI then you should be able to suspend using Fn-F12 now.

For more information on this topic see the Software Suspend 2 howto at the gentoo linux wiki.

Setting up a bootsplash using fbsplash

For those who don't know what a bootsplash is(eg. those who haven't used SuSE or gentoo yet), a bootsplash is a background image displayed when booting up and on all specified ttys. Fbsplash is the default method to creat a bootsplash on gentoo. To use fbsplash you have to first have it properly enabled in the kernel, for instructions see the kernel section.

The first thing you need to do is to run emerge splashutils. Then run etc-update to automatically update your config files. Now you need to create an initial ram disk for the bootsplash image, do that by running: bash-2.05b# splash_geninitramfs -v -g /boot/fbsplash-eergence-1024x768 -r 1024x768 emergence o Creating directory structure.. o Copying /sbin/splash_helper.. o Copying themes.. - emergence o Creating initramfs image..

KDE with KMilo plugin for thinkpad buttons


S3 Sleep clock problem fix


External Sources