Installing Gentoo on a ThinkPad R51-1830

From ThinkWiki
Revision as of 21:36, 28 October 2007 by TpUser0 (Talk | contribs) (New structure, typos, enhancements)
Jump to: navigation, search
This page is far from being complete and will be updated soon... --“TpUser0” 18:57, 22 August 2007 (UTC)


This page shows some parts of how I did once install Gentoo Linux on my ThinkPad. Since the R51 is now quite outdated (2005) everyone having such a laptop surely has his/her system installed already. So why this page?

Mainly out of interest and for fun.

The plan is to update the instructions on how to get the hardware running on a recent Gentoo Linux system. So it should be useful to everyone, even if he/she doesn't use a R51.

If you also own a Thinkpad R51 (machine types 1829, 1830, 1831 and 1836) feel free to add what you think is missing.

System specifications

Machine: IBM ThinkPad R51 1830-DG4

  • Pentium M 1.7 GHz
  • 1.5 GB PC2700 DDR RAM (I upgraded by 1 GB)
  • 100 GB Western Digital HDD (upgraded, not original)


00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 03)
00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 01)
00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 01)
00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 01)
00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 81)
00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 01)
00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)
00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 01)
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon RV250 [Mobility FireGL 9000] (rev 02)
02:00.0 CardBus bridge: Texas Instruments PCI4520 PC card Cardbus Controller (rev 01)
02:00.2 FireWire (IEEE 1394): Texas Instruments Unknown device 802a (rev 01)
02:01.0 Ethernet controller: Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)
02:02.0 Network controller: Intel Corporation PRO/Wireless 2200BG Network Connection (rev 05)



The laptop originally came with an 80 GB Hitachi hard disk drive.

TpUser0@localhost # fdisk -l /dev/hdc

Disk /dev/hdc: 80.0 GB, 80026361856 bytes
240 heads, 63 sectors/track, 10337 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1        9736    73604128+   c  W95 FAT32 (LBA)
/dev/hdc2            9737       10337     4543560   12  Compaq Diagnostics

When I received the ThinkPad I did not switch it on right away! I did also not start Windows XP!

A cronological list of what I did, and why I did it the way I did it:

  • Since I had a 2.5″ IDE adaptor I removed the HDD from the ThinkPad and put it in my desktop computer.
    Use a Knoppix Live Linux (or any other Linux Live distribution) on CD/DVD/USB-Stick if you don't have an adaptor. Be aware that the boot process has to start from this device, otherwise the HDD will be used – and once Windows gets started, it configures itself for the first run. Stop the boot process by entering the BIOS setup (press F1 when you see the IBM ThinkPad logo) and altering the boot sequence.
  • I made a backup of each parition. Back in 2005 I used partimage.
    Use a program of you choice or even dd if you prefer, but keep in mind that it should also work if you change the parition sizes and positions. If I had to do it now I would use Drive Snapshot, which is a Windows program. For this purpose I would have to boot from a Part PE Windows Live system to not alter the original partition.
  • I resized the Windows partition from its almost 75 GB to 20 GB using parted.
    Note: the original partition is a FAT32 file system. This makes it a lot easier for Linux to resize the partition, although ntfsresize does a good job too.
  • I made an image of the resulting partition too.
  • I deleted the second partition which is the rescue partition. Since I now had my own rescue images I didn't need it anymore.
    You will have to turn off the "Rescue Partition" feature in the BIOS to do this!
  • I then booted into Windows XP for the first time (!) and set it up to suit my needs.
    My system always converts FAT32 to NTFS and installs all the programs that came with the ThinkPad. I then need to install Service Pack 2 and all other recent updates for Windows and all the other programs I use. The Software Installer from IBM or Lenovo installes all required programs. You will need a broadband internet connection though, or you have all the files at hand (offline update). Another partition image of a recent and updated configuration will save your time for future Windows XP recoveries.
  • I then partitioned the rest of the hard disk with Linux and installed Gentoo Linux according to the manual.
    In my case I just copied an existing installation from my desktop to the ThinkPad and re-emerged everything with the correct CFLAGS and USE flags.

My partition layout (after I upgraded to a 100 GB hard disk):

tpuser0@localhost # fdisk -l /dev/hda
Disk /dev/hda: 100.0 GB, 100030242816 bytes
240 heads, 63 sectors/track, 12921 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        2774    20971408+   7  HPFS/NTFS
/dev/hda2   *        2775        2779       37800   83  Linux
/dev/hda3            2780       12921    76673520    5  Extended
/dev/hda5            2780        5943    23919808+  83  Linux
/dev/hda6            5944       12726    51279448+  83  Linux
/dev/hda7           12727       12921     1474168+  82  Linux swap / Solaris

As you can see I have

device mount point description and notes
/dev/hda1  /mnt/windows 20 GB reserved for the Windows XP installation
I bought it with the laptop, so why not use it from time to time?
/dev/hda2  /boot 40 MB for the kernels...
/dev/hda5  / 25 GB for the root directory
I figured it be best to have no seperate partitions for / and /usr...
/dev/hda6  /home 53 GB for all my personal files (and I have a lot of them!)
/dev/hda7  swap 1.5 MB
You need at least the size of RAM you have in your system for swap or hibernation will not be possible.

Gentoo Linux installation

  1. /etc/make.conf:
    • #=== hardware ===
    • ALSA_CARDS="intel8x0 intel8x0m virmidi dummy"add "usb-audio" if you have additional devices such as TV capture cards.
    • VIDEO_CARDS="radeon fbdev dummy vesa"add "fglrx" for the proprietary driver from ATI.
    • INPUT_DEVICES="keyboard joystick mouse synaptics"
    • SANE_BACKENDS="genesys"if you have a scanner, add your SANE backend here.
    • #=== host settings optimizations ===
    • CHOST="i686-pc-linux-gnu"
    • CFLAGS="-O2 -march=pentium-m -fomit-frame-pointer -pipe"I'm using very stable settings here because I want to work with my laptop, not tune it for crashing all the time...
    • #=== portage ===
    • Most of the other settings are explaned in /etc/make.conf.example – don't forget to add them too!
    • SYNC="rsync://"use mirrorselect
    • FEATURES="sandbox ccache parallel-fetch userfetch userpriv usersandbox"
    • USE=" your USE flags here "use ufed (Use Flag EDitior)


CPU: Pentium-M (Banias)

This is the first and original Intel Pentium-M processor, also known under the name Centrino (Intel Pentium-M + Intel i855 chipset + Intel PRO network card = Intel Centrino). It derives from the Intel Pentium III processor, improved by Intel Enhanced SpeedStep power management capabilities and added SSE2 instruction set.

Add the following compiler flags to /etc/make.conf:

CFLAGS="-O2 -march=pentium-m -fomit-frame-pointer -pipe"

These flags require at least GCC 3.4. They are optimized for stability and a good compromise between speed and file size.

See also: “GCC Optimization Flags for the Intel Pentium M (Banias)

Graphics: ATI Radeon Mobility 9000

XOrg X11

The ATI Radeon Mobility 9000 is fully supported by the open souce radeon driver.

Install X11 (I use XOrg X11):

tpuser0@localhost # echo VIDEO_CARDS="radeon" >> /etc/make.conf
tpuser0@localhost # emerge x11-base/xorg-x11

Prepare /etc/X11/xorg.conf: make sure you load the necessary X11 modules:

# a piece of /etc/X11/xorg.conf
Section "Module"
    Load	"GLcore"
    Load	"dri"
    Load	"glx"

Prepare /etc/X11/xorg.conf: create a dri group and restrict access to the DRI driver for users in that group (replace “408” by the group id of your dri group):

# a piece of /etc/X11/xorg.conf
Section "DRI"
    Group	408	# group "dri", next available id 408
    Mode	0660

Prepare /etc/X11/xorg.conf: the 15″ TFT flat panel:

# a piece of /etc/X11/xorg.conf
Section "Monitor"
    Identifier	"Monitor1"
    VendorName	"IBM"
    ModelName	"LCD Panel ThinkPad R51"
    Option	"dpms"

Prepare /etc/X11/xorg.conf: finally, the xorg-x11 radeon driver:

# a piece of /etc/X11/xorg.conf
Section "Device"
# ATI Radeon R250 (ATI Radeon Mobility 9000 M9)
    Identifier	"ati-xorg"
    Driver	"radeon"
    BusID	"PCI:1:0:0"
    Option	"DynamicClocks"	"true"
    Option	"RenderAccel"	"true"
    Option	"EnablePageFlip"	"true"
    Option	"BackingStore"	"true"

For more performance in X11 I also played with some additional parameters in /etc/X11/xorg.con, with various effects:

# a piece of /etc/X11/xorg.conf
Section "Device"
# ATI Radeon R250 (ATI Radeon Mobility 9000 M9)
    Identifier	"ati-xorg"
    Driver	"radeon"
    BusID	"PCI:1:0:0"
    Option	"DynamicClocks"	"true"
    Option	"RenderAccel"	"true"
    Option	"EnablePageFlip"	"true"
    Option	"BackingStore"	"true"
    #Option	"AGPFastWrite"	"on"	# ERROR: mplayer/xine/... xv (xvideo) modules don't work anymore!
    #Option	"DDCMode"	"true"	# use DDC (monitor) data to calculate mode lines
    #Option	"AccelDFS"	"on"	# (disabled by default for AGP due possible problems)
    #Option	"FBTexPercent"	"0"	# with EXA: (set to 0: reserve all offscreen RAM for EXA, OpenGL textures only in GART memory)
# CRASH options:
    #Option	"AGPMode"	"2"	# CRASH! (with or without AGPFastWrite)
    #Option	"AGPFastWrite"	"on"	# CRASH! (with AGPMode "2")
# SLOW options:
    #Option	"AccelMethod"	"EXA"	# newer and faster (!?) acceleration method



Trackpoint, Touchpad and USB mouse


UltraBay Enhanced hotswapping

If you want to be able to hotswap UltraBay Enhanced devices while running Linux you need a recent Linux kernel which supports ata_piix and preferrably the new generic bay driver. A recent kernel is 2.6.23 (2007-10-10) or newer.

Corresponding kernel configuration (/usr/src/linux/.config):


Alternatively the drives can be compiled into the kernel. If compiled as modules (as in my example), the bay module needs to be added to the /etc/modules.autoload.d/kernel-2.6 file:

 tpuser0@localhost # echo bay >> /etc/modules.autoload.d/kernel-2.6

With the generic bay driver udev should be used. Create /etc/udev/rules.d/60-ibm-ultrabay.rules and add the following:

ENV{BAY_EVENT}=="3", KERNEL=="bay.0", ACTION=="change", SUBSYSTEM=="platform", RUN+="/usr/local/sbin/ultrabay_eject"
ENV{BAY_EVENT}=="1", KERNEL=="bay.0", ACTION=="change", SUBSYSTEM=="platform", RUN+="/usr/local/sbin/ultrabay_insert"

Get the required scripts (ultrabay_eject and ultrabay_insert) from “How to hotswap UltraBay devices”.

If you use an older kernel (pre-2.6.23) you need to utilize HAL to get the UltraBay Enhanced hotswappable. As you can see from the lspci output this system has an Intel 82801DBM (ICH4-M) south bridge (PCI ID 00:1f.1). Just follow the instructions from “How to hotswap UltraBay devices” and configure HAL with ID 8086_24ca. I used the lshal command to find out the required ID of the south bridge for HAL.

Kernel configuration




Configuring relevant kernel modules


External Sources