Difference between revisions of "Installing Gentoo 2007.0 on a ThinkPad R61"

From ThinkWiki
Jump to: navigation, search
m (xorg.conf: more minor fixes)
m (xorg.conf)
Line 558: Line 558:
     Option        "UseEdidFreqs" "false"
     Option        "UseEdidFreqs" "false"
     # power savings
     # Allows the driver to enable VBlank interrupt generation only when it is required
    # Saves power, as there are less wakeups
     Option        "OnDemandVBlankInterrupts" "true"
     Option        "OnDemandVBlankInterrupts" "true"
Line 570: Line 571:
     # speed up 2d by actiavting the RENDER extension and using
     # speed up 2d by actiavting the RENDER extension and using
     # DAMAGE to only update regions of the screen which actually changed.  
     # DAMAGE to only update regions of the screen which actually changed.  
    # Also activating BackingStore which keeps pixel data for occluded window regions
    # and activating TripleBuffer. ARGBGLXVisuals are now enabled by default
     Option        "RenderAccel" "true"
     Option        "RenderAccel" "true"
     Option        "UseEvents" "false"
     Option        "UseEvents" "false"

Revision as of 18:35, 29 September 2008


Lenovo Thinkpad R61 7743-Y1B


This installation instruction describes the steps after a Gentoo 2007.0 base installation. Please read the gentoo handbook for installation instructions


  • Keyboard, UltraNav input (Touchpad and NavPoint)
  • Drives
  • X11 with nVidia including acceleration
  • Network, wireless network and bluetooth
  • Sound
  • Suspend to RAM
  • Suspend to Disk (Hibernate)
  • ThinkLight
  • ACPI (Battery, CPU Frequency, Fan, Temperature, ...)
  • Fingerprint scanner (includes login and screen lock)
  • Fn Key combinations
  • Hot swapping of optical drive (UltraBay)
  • HDD Acceleration Meter (can be used as an input device)
  • Harddisk protection (kernel patched with this)

Not tested:

  • Firewire (should work as it is recognized, no devices for testing)
  • Express Card Slot (should work, no devices for testing)
  • Docking Station (should work according to several sources, no devices for testing)

Graphics: NVIDIA Quadro NVS 140M

To install and configure the nVidia driver, just emerge nvidia-driver. Tested with nvidia-driver-100.14.19 up to 169.12, everything works fine, games run smooth.

Framebuffer works fine with vga=869 which will set the resolution to 1440x900. hwinfo --framebuffer displays all supported resolutions.

The brightness can be changed with newer nvidia drivers (>=169.04) Does not work with older drivers, only known workaround is to either use vesa / nv driver or to change the brightness on a vt.

Performance of the card depends heavy on powermizer and some nvidia settings.

I recommend you read my Xorg.conf, put the following settings in an autostart

nvidia-settings -a InitialPixmapPlacement=2 -a GlyphCache=1 &

and use this script:

while true; do
    powerstate=`cat /proc/acpi/ac_adapter/AC/state | awk '{print $2}'`
    if [ $powerstate = "on-line"  ]; then
       nvidia-settings -q all > /dev/null
    sleep 25;

which forces powermizer to stay on level 2 while your thinkpad is on AC power, not battery. (You can remove the if to keep it on level 2 even on battery, but this consume more power)

I recommend to get the nvidia driver 177.68 or newer, as some major RENDER improvements increased the speed, especially with Qt4 and KDE4, dramatically.

Sound: AD1984

Did not work with older Versions of ALSA driver, works fine with ALSA 1.0.15 and should work with ALSA 1.0.14 as well. The in-kernel ALSA works since 2.6.23.

The mute button is hardwired and works, the volume up and volume down buttons work as well but you need to configure them first. You can use xmodmap to bind a key to them and then either bind a amixer command to them, or set them as hotkeys in your mixer application (kmix, gnome-mixer, ...) Please note that some mixer applications take the wrong mixer (the microphone) as the default, so you have to change the default / primary mixer in order to use things like kmilo.

Note: After muting you have to press a volume up or down button to unmute, and the mute status is not displayed in any mixer application.

Note for Kernel 2.6.24: Due to changes in thinkpad acpi the mute button does not longer work out of the box, but it does generate a key event. So you have to bind it to a script which mutes the headphone and speaker via amixer toggle <mixer>. This is a known problem to the thinkpad-acpi developers and probably will be resolved in the near future.

I recommend using alsa-drivers 1.0.16, as there is a new master mixer, which has mute capabilities to mute headphones and speaker. So you can either bind the key in a mixer application or you only have to use one amixer command.

Network: Intel E1000 NIC, IPW4965abgn WNIC, Bluetooth

The integrated e1000 LAN NIC works out of the box.

For wireless you have to unmask and emerge the iwlwifi package with the ipw4965 USEFlag enabled.

Don't forget that the interface (wlan0) has to be set as up (ifconfig wlan0 up) before scanning and associating works.

Bluetooth works out of the box with blueZ. You can disable / enable bluetooth via proc, with a script similar to this one:


  1. !/bin/sh

bluetooth=`head -n 1 /proc/acpi/ibm/bluetooth | awk '{print $2}'` case "$bluetooth" in

       echo "enable" > /proc/acpi/ibm/bluetooth


       echo "disable" > /proc/acpi/ibm/bluetooth

esac exit 0 </bash>

or directly with the proc interface. This script helps you to bind it to the Fn+F5 key combination.

Note that the hardware killswitch on the front works as well, but disables both bluetooth and WLAN

If you desperately want the wireless LED to work you can use this patch for a 2.6.24 kernel. Make sure to enable LED Triggers and LED groups in your kernel configuration, then there is a new option in the iwlwifi submenu. Works here, however, it doesn't blink on activity as it would with windows.

Ports: PCMCIA, USB, IEEE 1394 Firewire

PCMCIA port works out of the box, tested with an audigy pcmcia. I have no express slot cards available for testing.

The left hand usb ports generate an IRQ nobody cared error from time to time, Try to boot with irqpoll in your kernel line as suggested.

A BIOS Update might help as well, it is recommended to use the ThinkVantage Software Updater for windows for a BIOS Update. The error disappeared here and USB works fine.

Firewire is untested but should work, as the port is recognized and the module loaded.


The optical drive and hard drive work out of the box, with AHCI disabled or enabled in the BIOS.

If you run a dualboot system with windows <= 5.1 (XP) you probably want to disable AHCI anyway, at least until you have installed the ahci driver for Windows.



Works out of the box here, with scrolling. Have a look at my Xorg.conf section at the end

Can be disabled via synclient when using the synaptics driver, a possible solution is this script:


  1. !/bin/sh

touchpad=`synclient -l | grep TouchpadOff | awk '{print $3}'` case "$touchpad" in

       synclient TouchpadOff=0;

echo "Touchpad Enabled" | osd_cat -d 1 -c cyan --font="-*-times-bold-r-*--34-240-*-*-p-*-*-*" -A center -p bottom ;;

       synclient TouchpadOff=1;

echo "Touchpad Disabled" | osd_cat -d 1 -c cyan --font="-*-times-bold-r-*--34-240-*-*-p-*-*-*" -A center -p bottom


esac exit 0 </bash>

which needs xosd to display the current state. You can make it excecutable and map it to the fn+f8 button.


Works out of the box as well, with no scrolling however. Can be configured via xorg.conf, I prefer using the middle button as mouse3.


Works out of the box, most of the Fn Keys work.

Hardwired: Mute, Thinklight, Brightness

Generates a keycode and can be configured: Volume Down, Volume Up, Fn+F2, Fn+F3, Fn+F4, Fn+F5, Fn+F7, Fn+F8, Fn+Arrows

Does not generate a key event: Fn+F9, Fn+F12, Fn+Space Those keys do produce an acpi event, so you can modifiy your acpi configuration to bind them to commands.

It is also possible to translate the acpi events to keyevents, have a look at the following configuration file:

My example default.sh file for the missing keys is here and there is a good, more complete howto here: Gentoo Wiki

Try whether echo "0xffffffff" > /proc/acpi/ibm/hotkey enables additional fn+fx keys to produce a key event instead of only an acpi event. Take a look at the ibm-acpi section as well to do this on module load.


Suspend to RAM worked out of the box here, echo 3 > /proc/acpi/sleep puts the machine in suspend mode, opening it or pressing the power button wakes it up. Worked with nvidia driver and in X11. All devices came back without problems, wlan might have disconnected, but by using networkmanager, wicd or a good configuration it should reconnect after waking up. Works here with wicd.

Suspend to Disk is more complicated. Emerge a tux on ice kernel and try the configuration file linked at the end of this page. Disable intel-agp in the kernel. Make sure to load the nvidia module with NVreg_NvAGP=1 option.

This is my /etc/hibernate/common.conf file. Note that all options not mentioned here are commented (#)

Verbosity 0
LogFile /var/log/hibernate.log
LogVerbosity 3
HibernateVT 11
Distribution gentoo
# XDisplay :0

### clock
SaveClock restore-only

### hardware_tweaks
IbmAcpi yes
FullSpeedCPU yes

### modules
# UnloadBlacklistedModules yes
LoadModules auto

### xhacks
SwitchToTextMode yes
UseDummyXServer yes
# DummyXServerConfig xorg-dummy.conf

Note that the extra_pages_allowance might be too low. In current TuxOnIce versions the option to raise this value did not work anymore, that's why I put

echo 1000 > /sys/power/tuxonice/extra_pages_allowance

in my local.startup.

You can get the correct value by trying to suspend without it and reading /var/log/hibernate.log afterwards.

The machine can now be suspended to disk with the hibernate command.

Integrated Fingerprint Reader

Emerge the thinkfinger package, add a user with the tf-tool. Then you have to edit the /etc/pam.d/system-auth file by adding

auth sufficient pam_thinkfinger.so

between pam.unix and pam.env.

Read the Gentoo-Wiki to use it with xscreensaver, there is a good solution over there

Note: kdm has problems with thinkfinger auth and might crash. There are patches, but I didn't test them yet. gdm works fine here.

Hard Drive Active Protection

The integrated harddrive active protection acceleration meter can be used as a joystick or to get information about movements of your thinkpad.

Emerge the hdapsd (which includes a kernel module you have to load) which will generate a joystick and an event device.

It can be used for protecting your harddisk as well. You first need to patch your kernel with this patch and then rebuild it. Make sure to diable the kernel internal hdaps module, emerge hdapsd and tp_smapi with the hdaps flag enabled, rc-update add hdapsd boot and then reboot.

When shaking your notebook you should receive a message via dmesg that the hdd head has been parked. You can also use a frontend like khdaps.

Heads will only be parked with this method. However, in some situations and with some disk there will be a full spindown, which should be avoided as this might damage your harddisk when used too much.


The thinklight works out of the box with the Fn+PgUp key, but it can be controlled as well via the proc interface.

So you can write a nice script, which you can bind to events, such as incoming emails, to let the light flash.

A possible solution is this small script:


  1. !/bin/sh

if [ -z "$1" ] then echo "IBM ThinkLight Control script." echo "2007 by Christian \"Fuchs\" Loosli." echo "" echo "usage: lightctl on | off | toggle | blink" echo "blink takes two arguments: times and time" echo "defaults (5 times, 0.5 seconds) are used if not specified"

else if [ $1 = "on" ] then

   	       echo on > /proc/acpi/ibm/light

fi if [ $1 = "off" ] then

  	       echo off > /proc/acpi/ibm/light


       if [ $1 = "toggle" ]

then status=`cat /proc/acpi/ibm/light | grep status | awk '{print $2}'`

if [ $status = "on" ] then echo off > /proc/acpi/ibm/light else echo on > /proc/acpi/ibm/light fi fi

if [ $1 = "blink" ] then

times=$2 time=$3

if [ -z "$2" ] then times=4 fi

if [ -z "$3" ] then time=0.5 fi

   	        for i in `seq 1 $times`;
   		        $0 toggle;
                       sleep $time;
                       $0 toggle;
                       sleep $time

fi fi exit 0

</bash> which can be called to let the light blink or switch it off or on. The blink part is nice for setting to events such as incoming messages or emails.

There is a version slightly modified by a friend of mine here which has a lockfile and is slightly optimized.

(note: the thinklight is a LED, so it should not care on how fast and often you let it blink. But I am not responsible if this script damages your thinklight. Use at own risk.

Power saving

First of all, turn off all things you are not using, most of all bluetooth and W-LAN. You can use the killswitch on the front, it works out of the box.

You can use the application powertop by Intel to look for processes which prevent the CPU from longer sleep states.

It also gives you some recommendations on services to turn off. Do _not_ turn off the optical drive polling by HAL.

Dimming the display also saves lots of power.

Since 2.6.24 dynticks are available for x86_64.

I managed to get powerconsumption down to:

  • 20W running normal with compiz, wlan & bluetooth enabled
  • 16.7W running a normal windowmanager
  • 14.5W with bluetooth and wlan disabled (killswitch)

I had between 195 and 600 wakeups per second.

Also hda-intel and s-ata power consumption was reduced in 2.6.24

You can achieve about 2 - 3 hours of working time (no compiling or other heavy CPU / GPU usage applications) with the standard battery like this.


I have ibm-acpi configured as a module in my kernel, as I load it with

options thinkpad_acpi hotkey=enable,0xffffffff brightness_enable=1 fan_control=1

to enable brightness controll via /proc/acpi/ibm on newer kernels and fan control. The hotkey=enable,<mask> option is used instead of writing to /proc/acpi/ibm/hotkey.

The default file permissions in /proc/acpi/ibm/* do not grant write access for users. I created the group "ibm", added my users to it and now I chown root:ibm and chmod 0774 the files in /proc/acpi/ibm/ on startup. If you don't want to do this you might use sudo sh -c "echo "foo" > /proc/acpi/ibm/whatever", but you need to install sudo and modify your sudoers file.

Configuration Files


Note that I use the XFont Server, you might have to change the font path.

You also might want to change the keyboard layout.

' Note: in this configuration here nvidia wont read out sane refresh and sync values out of your flat panel.

In this configuration the modes given don't affect the modes available and you will have all screen resolutions available, but it might fail on other display devices.

If you get a blank screen or strange refresh values, add # in front of the marked line to disable this behaviour, so the nvidia driver will still read out sane resolutions.

## Server layout for the built in monitor, an external mouse and the touchpad
Section "ServerLayout"
    Identifier     "single head configuration"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Touchpad" "CorePointer"
    InputDevice    "LX8" "SendCoreEvents"

## FontPath for the x font server xfs
Section "Files"
    FontPath        "unix/:-1"

## Module Section, load default modues
Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "glx"
    Load           "freetype"
    Load           "type1"

## Keyboard section, layout is swissgerman
Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
    Option         "XkbModel" "pc105"
    Option         "XkbLayout" "ch"

## Touchpad section, values can be changed with synclient on the fly, 
## as SHMConfig and UseSHM allow this
Section "InputDevice"
    Identifier     "Touchpad"
    Driver         "synaptics"
    Option         "Protocol" "auto-dev"
    Option         "Device" "/dev/input/mouse0"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
    Option         "LeftEdge" "1700"
    Option         "RightEdge" "5300"
    Option         "TopEdge" "1700"
    Option         "BottomEdge" "4200"
    Option         "FingerLow" "25"
    Option         "FingerHigh" "30"
    Option         "MaxTapTime" "180"
    Option         "MaxTapMove" "220"
    Option         "VertScrollDelta" "100"
    Option         "MinSpeed" "0.02"
    Option         "MaxSpeed" "0.28"
    Option         "AccelFactor" "0.0010"
    Option         "SHMConfig" "on"
    Option         "UseSHM" "true"

## External Logitech LX8 Mouse
Section "InputDevice"
    Identifier     "LX8"
    Driver         "evdev"
    Option         "CorePointer"
    Option         "Name" "Logitech USB Receiver"
    Option         "Buttons" "9"
    Option         "ZAxisMapping" "4 5 6 7"
    Option         "HWHEELRelativeAxisButtons" "7 6"
    Option         "Resolution" "1600"

## Built in Monitor with power saving features enabled 
## and manually specified frequencies as the EDID is a bit broken
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Lenovo"
    ModelName      "LEN"
    HorizSync       28.0 - 61.0
    VertRefresh     43.0 - 62.0
    Option         "DPMS"

## Videocard section. Some of the following options are now default
## and only kept for compatibility reasons with older drivers
## Read the Appendix B of the nvidia README for explanations 
Section "Device"
    Identifier     "Videocard0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro NVS 140M"

    # bus options (disable agp and specify the bus ID (pci-e)
    Option         "NvAGP" "0"
    BusID          "PCI:1:0:0"
    # do not use the frequencies provided by the monitor edid 
    Option         "UseEdidFreqs" "false"
    # Allows the driver to enable VBlank interrupt generation only when it is required
    # Saves power, as there are less wakeups
    Option         "OnDemandVBlankInterrupts" "true"
    # allow underclocking
    Option         "Coolbits" "1"
    # enable the X Resize and Rotation extension
    Option         "RandRRotation" "true"

    # speed up 2d by actiavting the RENDER extension and using
    # DAMAGE to only update regions of the screen which actually changed. 
    # Also activating BackingStore which keeps pixel data for occluded window regions
    # and activating TripleBuffer. ARGBGLXVisuals are now enabled by default 
    Option         "RenderAccel" "true"
    Option         "UseEvents" "false"
    Option         "TripleBuffer" "1"
    Option         "DamageEvents" "1"
    Option         "BackingStore" "1"
    Option	   "AllowIndirectPixmaps" "true"
    Option	   "AddARGBGLXVisuals" "True"

    # pixmap speedups since 177.* driver version 
    # this will reserve about 5 MB of video memory for pixmaps 
    # If some applications (e.g. xchat) need SHM Pixmaps then remove the second line
    # Set InitialPixmapPlacement to 2 and GlyphCache to 1 for massive performance gains
    Option         "PixmapCacheSize" "1000000"
    Option         "AllowSHMPixmaps" "False"

## Screen Section
Section "Screen"
	Identifier   "Screen0"
	Device       "Videocard0"
	Monitor      "Monitor0"
	DefaultDepth  24
	Option       "AddARGBGLXVisuals" "true"
	Option	     "UseCompositeWrapper" "true"
	SubSection "Display"
		Viewport  0 0
		Depth     24
		Modes     "1440x900" "1024x768" "800x600" 
	SubSection "Display"
		Viewport  0 0
		Depth     16
		Modes	  "1440x900" "1024x768" "800x600" 
	        SubSection "Display"
	        Viewport  0 0
		Depth     8
		Modes     "1440x900" "1024x768" "800x600" 

## Extensions, load composite for compiz (should be default by now) 
Section "Extensions"
    Option         "Composite" "Enable"

## DRI Section, deprecated
Section "DRI"
	Group        0
	Mode         0666


Note: you have to xmodmap /path/to/file this file in your autostart. You might have different keycodes, use the application xev to display them. It is highly recommended to use the XF86foobar buttons, as some applications will be preconfigured to them. If you want to map them by yourself use Fxx, while xx > 12.

! additional Arrow keys

keycode 233 = XF86Forward
keycode 234 = XF86Back

! Fn+arrow keys

keycode 144 = XF86AudioPrev
keycode 162 = XF86AudioPlay
keycode 153 = XF86AudioNext
keycode 164 = XF86AudioStop

! Fn+Fx keys  F2, F3, F4, F5, F7, F8, F9, F12  in this order

keycode 146 = XF86ScreenSaver
keycode 241 = XF86Display
keycode 223 = XF86Sleep
keycode 243 = XF86Send
keycode 214 = XF86Video
keycode 196 = XF86iTouch
keycode 197 = XF86Eject
keycode 165 = XF86Standby

! Space bar

keycode 148 = XF86ZoomIn

! volume control (mute is hardwired)

keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume

default.sh (acpid)

This is my slightly modified default.sh file to handle ibm hotbutton events. Of course you can add the other buttons as well, however, as they produce key events there are easier ways for configuring the actions. However, an acpi solution is window manager / X independent.

You can read out the key events, as they might differ on your model, with the acpi_listen application.


  1. !/bin/sh
  2. /etc/acpi/default.sh

set $*

group=${1%%/*} action=${1#*/} device=$2 id=$3 value=$4

if [ "$group" = "ibm" ]; then key="$2"\ "$3"\ "$4" fi

log_unhandled() { logger "ACPI event unhandled: $*" }

case "$group" in button) case "$action" in power) /sbin/init 0 ;;

*) log_unhandled $*


esac ;;

ibm) case "$action" in hotkey) case "$key" in "HKEY 00000080 00001008") /usr/bin/acpi_fakekey 220 ;; "HKEY 00000080 00001009") /usr/bin/acpi_fakekey 221 ;; "HKEY 00000080 00001014") /usr/bin/acpi_fakekey 222 ;; *) logger "acpid: $group/$action $key is not defined" ;;

esac ;; *)


esac ;;

*) log_unhandled $*


esac </bash>

Note that I use acpi_fakekey to translate acpi to key events.

ACPI Fakekey

With this nice app you can translate acpi events into key codes.

I borrowed it from gentoos acpi-support, which borrowed it from Ubuntu people.

You can it out of the sunrise overlay, I recommend only getting the acpi-fakekey.c file and compile it.

For the lazy guys:

There is an explanation and the source code, which I wont copy and paste here, on this page:

Gentoo Wiki on Hotkeys

I use this in the file above to generate keycodes for Fn+F8, Fn+F9 and Fn+Space.

Kernel configuration

2.6.24 TOI Kernel config

Please note: this configuration works for my setup, it might not for yours.

I use ext3 as my file system, make sure to compile in the support for the file system you are using, at least for the root partition.

I also use external ALSA drivers. But I use lots of stuff you probably will never use, such as several gamepads, acl support for ext3, some ipv4 / ipv6 filters ... You might want to remove those.

This is the configuration for a 2.6.24 Kernel, it differs a little bit from the configuration of earlier kernels.

Unstable Kernels and updates

Recently, 2.6.25-tuxonice hit portage, ~masked. If you'd like to to update there are several important changes.

1) you'll need two new hdaps patches, here and here.

2) you might want to patch iwlwifi to the newest version, with working LEDs. A patch can be found here, original from here

Please note: I can't guarantee that the patches above will work, nor I can guarantee that they don't screw your system. They work fine here, but might not on your computer. I am not responsible for whatever happens when you use them.

Those patches can be applied with patch -p1 < $patchname in your linux directory. Please note that in kernel ALSA should be used, as 1.0.16 (which is in kernel) fails to compile.

3) The nvidia drivers in portage do _not_ work with 2.6.25. You either have to install 173.08 (beta at the moment) or patch the older ones, as described here

There will be a NVRAM warning in dmesg on x86_64, which, according to nvidia, can safely be ignored or removed by using this patch

My 2.6.25 kernel config is here (for tuxonice and wireless patched)

Use at own risk, and note that I use ext3 as filesystem and ahci for the hdd.