Saturday, May 01, 2004

Gentoo Linux on the IBM Thinkpad R40

Yes, yes. I got myself a new toy ... er ... a new Laptop. It's an IBM Thinkpad R40. I'm pleasantly surprised that most of the hardware runs perfectly on Linux, something unimaginable just a couple years ago. Anyway, getting all of it to work with the geek-oriented Gentoo distro is a saga worth of reference. If you have a Thinkpad, it's probably interesting to review my steps.

Before you start

Don't boot the computer into windows. The Thinkpad comes preinstalled with Windows XP. The XP partition uses all of the available disk, which is incompatible with running Linux on dual boot. It's necessary to resize it. Before the first boot, the partition is a FAT32 partition, and will be converted to NTFS on the first windows boot. FAT is a much more documented filesystem than NTFS, so resizing tools are much more stable.

In case you did boot the first time, press the "Access IBM" button on startup, and select "Recover to factory contents". When the recovery software asks for a reboot, do a hard reboot (power-off and then power-on), so the "Access IBM" button gets re-enabled, and then proceed to the next step.

If you already have windows installed, and don't want to bork the install, have a look at NTFS resizing tools, like ntfsresize or QTParted. Most of these tools are less than perfect, so backup backup backup. You have been warned!

Boot into the Gentoo LiveCD

Get and burn the Gentoo install CD you wish to use. Follow the Gentoo Installation Handbook for choosing one. To boot from the CD, press the "Access IBM" blue button when the IBM logo appears. Select "Startup" and then the CD-ROM as your boot device.

Install Gentoo as usual

Follow the Gentoo install procedure. When it comes to defining your partitions, use parted to reduce the FAT32 partition. Then proceed as the manual tells you to.

Before running parted, run fdisk on /dev/hda and print out the partition table. Take note of the last cylinder of the FAT32 partition. This is the last usable cylinder. From here on is an undeclared partition containing service data for the "Recover to factory contents" procedure. Afterwards, when setting up partitions, don't use cylinders over the previous FAT32 last cylinder.

If the FAT32 partition is too small, the "Recover to factory contents" procedure won't work in the future. I set mine to 12GB. It should work with a 10GB partition [1]. The "Recover to factory contents" won't touch your Gentoo install, except for overwriting the Master Boot Record. If you do run the procedure, you'll need to reinstall the Linux bootloader (usually grub).

The command to resize the partition with parted is:
parted /dev/hda resize 1 0.031 12000
Note that this may change with laptop model versions, so I don't guarantee it works on every R40. Check current table with parted, and read parted help on the GNU site.

Gentoo fails detection of the eepro100 ethernet card. It finds the firewire interface and assumes one interface is all you need. Just run:
modprobe eepro100
net-setup eth1
When compiling the kernel, grab my .config. This is from a 2.6.6. Just place it into /usr/src/linux and run 'make oldconfig'. It'll be configured with all the necessary drivers. Proceed with compilation as usual.

When setting up grub, remember centrinos don't have floppies. It's quicker to pass --no-floppy to grub, to avoid waiting for auto-detection to fail. From then on, follow the handbook's instructions

Major compilation step ahead

After finishing the handbook, you should have a basic console based linux system. This is a desktop machine, so we're far from done with. Go for a full emerge (overnight ;-):
emerge vim xfree windowmaker   \\
gnome kde openoffice-bin \\
mozilla-firefox mozilla-thunderbird \\
eterm gaim tuxracer freeciv grip \\
xmms xine gimp
plug the power cord in, and go to sleep.

Major compilation step ahead

Wake up. Refreshed, go on configuring your fresh new Gentoo system.

Grab my /etc/X11/XF86Config-4. You may need to fiddle with the resolution (there are 1024x768 and 1400x1050 R40 variants). Use xf86cfg to edit the config.

Set DISPLAYMANAGER to gdm in /etc/rc.conf

Add xdm to the default runlevel:
    rc-update add xfs default
rc-update add xdm default
/etc/init.d/xdm start
Login as root, naturally select Windowmaker as the window manager. You should have a really usable linux system by now. Office tools, multimedia tools and internet access. Now, for the specific laptop hardware.

Centrino Wireless Drivers

To get the Centrino Wireless card working, I used the Intel drivers[6]. These are still under development, but I preferred this solution to using windows drivers over an adaptation layer (ndiswrapper). They work flawlessly. I was unable to install using the ebuilds in portage. However, it's rather easy building from source. The only obstacle I found is that with newer 2.6 series kernels, you have to configure at least one module, so that /usr/src/linux/Module.symvers gets built (if you used my .config above, don't worry about it).

After getting the drivers built, just insert the ipw2100 kernel module. You now have a second ethernet card (eth1). Configure it as indicated in the Gentoo Installation Handbook.

APM hibernation

I opted for APM instead of ACPI, since I've found lots of reports of flakiness of ACPI on Thinkpads. APM seems to work rather well. APM hibernation to RAM works out of the box (Fn-F4). There are a couple of driver issues:
The X server will sometimes hang after resume. Turning the LCD off and on again does the trick (Fn+F7 twice)

The USB mouse is unresponsive after resume. This is an X problem, since the /dev/input/mouse3 produces output when moving the mouse. Two workarounds: either unplug the mouse before suspending, or switch between virtual terminals after resuming. One more automatic solution could be installing apmd, have USB compiled as a module, and forcefully remove the module and reinsert it on resume. I may look into this option.

I haven't even tried to get hibernation to disk, but it's reported as feasible [4].

IrDA communication with my Nokia 6100

Winmodem

I don't have a need for the modem, so I haven't set it up. Instructions are here:
http://www-306.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-52698


References

References:
[1] Redhat 9 on an IBM Thinkpad G40, http://www.haviker.co.uk/tp/ , Dec 2003, Kieran
[2] http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml
[3] Linux on the IBM ThinkPad R40 laptop, http://www.luth.obspm.fr/~luthier/gourgoulhon/ThinkPad/ , Eric Gourgoulhon
[4] Linux on the IBM R40 2722-GDG, http://www.enseeiht.fr/~queinnec/ibm-r40.html , Philippe Queinnec
[5] Software and Device Drivers - ThinkPad R40, R40e, http://www-3.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-46024#INF
[6] Intel PRO/Wireless 2100 Driver for Linux, http://ipw2100.sourceforge.net/
[7] http://bugzilla.kernel.org/show_bug.cgi?id=1415

Links

http://tpctl.sourceforge.net/tpctlhome.htm#description
Posted by K at 00:41:52 | Permanent Link | Comments (12) |
Comments
1 2
1 - Nice. I was going to ask if you managed to get the Centrino wireless working without problems, guess this answers that question and a lot more. (Comment this)

Written by: André Restivo at 2004/05/01 - 01:51:00
2 - please, could you make the link to your X config file working? doesn't work now (Comment this)

Written by: r080 at 2004/05/19 - 09:50:04
3 - Just wondering if you\\‘d managed to get your touchpad working properly as well? You didn\\‘t mention it in your doco...

For anyone who\\‘s having trouble with it, emerge synaptics, read the documentation and you\\‘ll have it going in no time :) (Comment this)

Written by: Liam O\\\\\\\'Boyle at 2004/08/22 - 02:01:50
4 - Already have Mandrake 10.0 on an R40, perfectly successful, including internal modem, but am thinking of moving to more flexible system (Gentoo??), so this is encouraging. Not sure why you need to preserve the "Return to Factory Contents" element. Are you running Windows alongside Gentoo? (Comment this)

Written by: Ron Hickson at 2004/10/16 - 07:13:20
5 - Yup. (Comment this)

Written by: Sérgio Carvalho at 2004/10/17 - 11:15:04
6 - Thanks for a wonderful writeup! Could you provide the link to kernel .config file for 2.6.6 mentioned in chap. "Install Gentoo as usual"? (Comment this)

Written by: henrik at 2004/11/20 - 17:29:24
7 - Here: http://files.sergiocarvalho.com/2004/.config-2.6.8 (Comment this)

Written by: Sérgio Carvalho at 2004/11/22 - 15:15:33
8 - much thanks - saved me lots of time. still having difficulty with the wireless, but at least there\‘s hope. :-) (Comment this)

Written by: rand huso at 2005/01/11 - 18:37:10
9 - Everything seems to make sense, and in fact, I‘ve found that Gentoo runs pretty well on the R40. I‘ve played with a few other distros on here, and Debian until recently, but Gentoo 2004.3 seems to be going well.

There were two things I thought I‘d mention, because you brought them up in your writeup. ACPI under the current default installation seems to work nicely with Gentoo on this box, though YMMV. I did manage to get suspend to disk working fairly painlessly, though you want to make sure you‘re using a journalling filesystem if you‘re going to play with it.

There are wiki‘s out about it, but essentially the 2.6 series kernels include a "Software Suspend" option under the ACPI config. This basically backs up the current system memory to a swap partition that you specify. There is a second option that you can use to configure which partition you want to use by default, or it can be passed as a kernel boot parameter. Everything works nicely, though I have had some issues with the clock de-synching (which should be fixable with a quick script when I get around to it).

A word of warning though: if you *do* have problems with it, instead of resuming from the swap you will end up with a normal boot as if you had just cut the power (which is bad without a journalling filesystem), and you will need to re mkswap.

I was also wondering if you have had much luck with the IRDA port? Ideally I‘d like to use it to sync my older palm, so I suppose that‘s IRTTY.

Thanks,
Brendan Smithyman (Comment this)

Written by: Brendan Smithyman at 2005/01/25 - 15:46:47
10 - Olá, eu estava interessado em adquirir um portátil IBM e gostava de saber se o teu foi comprado em Portugal e se tem o teclado em português. Se tiveres tempo pra responder... por favor! (Comment this)

Written by: Telmo at 2005/03/28 - 01:53:40
Write a comment






1 2