Installing Linux on an IBM Thinkpad i series s30

i Series s30 photo (49k) This document explains in some detail how to install Linux on the machine you see in Figure 0 (the IBM model number of my unit is 2639-43J).  This information is provided with NO WARRANTY -- if this all goes wrong and you turn your laptop into an expensive paperweight don't come crying to me.  Having said that, additions and corrections to this doc are more than welcome.
Figure 0: a Thinkpad i Series s30 (select to see the image full-size)

Introduction

The official IBM page for this machine has more information.  There are a bunch more pictures of the s30 here.  To give you an idea of the size the dimensions with the extended battery (giving a quoted run time of 10 hours) are 24cm wide by 23 deep -- the standard battery is a bit slimmer, making the machine slightly less deep and a bit lighter, but gives "only" 6 hours.  It's 2.5cm high at the front when closed (1.5cm open), and between 3 and 4cm high at the back (there's a nifty tilty thing on the battery to tip it forwards for typing, and perhaps to improve airflow).  The keyboard is very slightly cramped, not ideal for those with poor coordination or fat fingers, but has a good feel and is better than that found on the Vaio picturebooks.  There are a few extra funky Japanese keys, and all the keys have Kanji symbols on them in addition to Roman characters.  I got the model with the built-in 10/100 Ethernet and FireWire rather than 802.11b; the mini-PCI radio card is apparently not yet supported under Linux.  The screen has small pixels (it's 1024x768 and measures about 21x16cm, giving approximately 124ppi), but is very clear and readable.

Linux and the hardware

Here are the I/O devices and what I know about Linux support for them:
Video
Video is a 4Mb Silicon Motion chipset, supported under XFree86 by the siliconmotion driver (XFree86 4 config file).
VGA output
The VGA port is a tiny socket which uses a dongle; since the battery attaches to the back there are no flat surfaces on this machine big enough for a full-size D15 socket.  The Fn-f7 key combination works to switch between LCD, LCD+CRT and CRT only.
Audio
There is a headphone and a microphone socket.  The hardware seems to be an Intel i810 supported by the AC97 driver (it works out of the box under RedHat, so there definitely is Linux support, I just need to figure out how to get it working under Debian).
Ethernet
Intel i82557, supported by the eepro100 driver (CONFIG_EEPRO100=y) .
Modem
Some kind of Winmodem; I don't yet know whether Linux will be able to use this or not.  My guess is not, but I'd be pleased to discover otherwise.
USB
This works fine; I have a USB floppy drive and a digital camera (Canon digital IXUS v) and they're working perfectly.
Firewire
I have no idea whether this works or not; I don't own any Firewire devices.
PCMCIA and Compact Flash
There is one of each of these sockets, and they work fine.  The PCMCIA socket is socket 0 and the Compact Flash socket 1.  I put the following line into /etc/fstab for my flash cards (I use the camera to write to them and format them, so mount them read-only to avoid unfortunate accidents):
/dev/hdc1 /flash vfat defaults,ro,user,noauto 0 0
summary of PCI bus devices (output of lspci)
00:00.0 Host bridge: Intel Corp. 82440MX I/O Controller (rev 01)
00:00.1 Multimedia audio controller: Intel Corp. 82440MX AC'97 Audio Controller
00:00.2 Modem: Intel Corp.: Unknown device 7196
00:07.0 Bridge: Intel Corp. 82440MX PCI to ISA Bridge (rev 01)
00:07.1 IDE interface: Intel Corp. 82440MX EIDE Controller
00:07.2 USB Controller: Intel Corp. 82440MX USB Universal Host Controller
00:07.3 Bridge: Intel Corp. 82440MX Power Management Controller
00:09.0 VGA compatible controller: Silicon Motion, Inc. SM720 Lynx3DM (rev b1)
00:0a.0 CardBus bridge: Texas Instruments PCI1420
00:0a.1 CardBus bridge: Texas Instruments PCI1420
00:0b.0 FireWire (IEEE 1394): Texas Instruments: Unknown device 8021 (rev 02)
00:0c.0 Ethernet controller: Intel Corp. 82557 [Ethernet Pro 100] (rev 08)
Power management
Perhaps I haven't configured things right yet, but power management on this machine seems to be poorly supported under Linux.  It seems that ACPI is the way of the future, but Linux support for this new standard is definitely not mature yet.  Unfortunately it seems that APM support in IBM's BIOS has suffered, and I have not managed to persuade the machine to resume after a suspend.  Likewise, the four "Thinkpad" buttons on the keyboard appear to be supported via ACPI, so they do nothing.  I have not yet tried ACPI, fearing 200k of development kernel code controlling cooling my CPU, and am relying on the BIOS to stop things from melting.  I haven't noticed any excessive heat, and kapm-idled seems to be doing its thing.  The poweroff button does work.
There is no IR port, which is a bit of a shame; it would have been nice to be able to sync to a Palm without having to bring a cable (USB of course; there is no serial port).  Finally, it's got a little light on the lid that shines on the keyboard when you press Fn-PgUp.  This does do some good if you're in pitch darkness but is frankly a bit of a gimmick.

Prerequisites:

Create a Windows ME boot disk

Make sure you've got your USB floppy drive connected, with a blank formatted floppy in it.  In Windows ME do the following: "start"  /  "settings" / "control panel" / "add/remove programs" / "startup disk" / "create disk" / "OK".  Remove & label the disk; you'll need this to boot so that you can run Partition Magic.

Create a Partition Magic rescue diskette

Partition Magic won't work from inside Windows ME (according to what I've read on the net, at any rate), so you need to make a disk to run it from after booting from the Windows ME boot disk you just made.
I used Partition Magic 4.0, which I installed over the network from the CD mounted in a Linux box running Samba.  If you have a USB CD-ROM drive that may be more convenient for you.  Run setup.exe from the CD, and you'll see a message as follows (Figure 1).

ignore this warning
Figure 1: ignore this warning
Note: if you cannot see the image above your browser probably does not support PNG graphics.  My apologies for the inconvenience; may I suggest you try a more recent browser ?

Ignore the warning and click "run program".  Follow all the defaults during the install process up until it asks you whether you want to make rescue and help diskettes (Figure 2).

make a rescue diskette
Figure 2: make a rescue diskette?

I wasn't interested in a help diskette, so I unchecked the box and hit next.  You get another chance to make a rescue diskette later.  Similarly, I didn't bother reading the README file, and am not interested in registering my software so did "cancel" / "never register" to that question.
Check your floppy drive is plugged in and double-click the "create rescue diskette icon".  You'll be prompted to insert a disk; insert one of your blank formatted ones.  You'll see this dialog box (Figure 3); click OK.

pointless dialog box
Figure 3: pointless dialog box

Next you'll be presented with this dialog (Figure 4); click Close.

another pointless dialog box
Figure 4: another pointless dialog box

Answer No when asked whether you want to transfer system files (Figure 5) -- this doesn't work.

don't transfer system files
Figure 5: don't transfer system files

Finally some files will get copied to your floppy -- in true Windows style the progress bar shoots immediately to 96% and then stays there for some time.  Eventually you'll see this window (Figure 6) letting you know everything went OK.

finished
Figure 6: finished

Once you've cleared that dialog you'll see a window asking if you want to create a help diskette (Figure 7).

help diskette?  we don't need help
Figure 7: help diskette? we don't need help

I cancelled out of this, but I guess you could create yourself a help diskette if you wanted.  You should now be back at your desktop, with a Partition Magic floppy in your sticky paws.

Reboot into "minimal boot"

Stick your Windows ME boot floppy into the drive, and reboot the machine.  You might have to diddle with the BIOS, but it is possible to set it up to boot off removable media in preference to the hard drive, and also so that you can press F12 & choose "removable media".  When you've got it right you'll see a menu looking something like this:
Microsoft Windows Millennium Startup Menu
==========================
   1. Help
   2. Start computer with CD-ROM support.
   3. Start computer without CD-ROM support.
   4. Minimal Boot
Enter a choice: 1
Choose "minimal boot" by typing 4 and pressing enter.  The machine should boot up and give you an old skool A:\> prompt.  Insert the Partition Magic rescue diskette you made and type
pqmagic
After a short period of clunking from the floppy drive you should see Partition Magic.  It will look hideous, due to the fact that it will only have 16 poorly dithered colours and will be stretched from 640x480 to fit your 1024x768 screen.  Don't worry, this is all good.

Repartition your drive

I made my drive look like this (Figure 8).  I didn't take notes while I was doing it, but it's not rocket science.

partition layout
Figure 8: partition layout

I would leave the IBM_SERVICE partition at the end of the disk well alone; I reckon this is either the .CAB files for Windows ME to install drivers and so on, or the hibernation partition, or both.  I left Windows with 6Gb of space; if you decide to vary this upwards heed any warnings Partition Magic gives you about the Linux partition not being bootable.  I decided not to use Partition Magic to make the Linux partitions inside the extended partition; I'm happy with fdisk thanks very much.
Apply the changes, exit Partition Magic, remember to remove the floppy from the drive, reboot, and check Windows still works.

Installing RedHat

I spent a good while trying to get the machine booting the Debian installer from the network with PXE -- I'm convinced that this could be made to work, but in the end it was too much pain.  In the end I decided to install Redhat first and use that to get Debian installed; if you like Redhat I guess you could skip the "installing Debian" step.  I downloaded the Redhat 7.2 network install floppy, booted from that, and installed onto the /dev/hda3 partition without incident.  I went with the GRUB bootloader, which is nice.  Here are my notes; although brief hopefully they'll be helpful as you go through the install:

Installing Debian

Once GRUB was on the hard drive installing Debian was much easier. From inside Redhat I repartitioned /dev/hda with fdisk, splitting up that 10Gb of free space as follows (Note: the ordering is a bit weird):

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       784   6297448+   b  Win95 FAT32
/dev/hda2          2280      2431   1220940   1c  Hidden Win95 FAT32 (LBA)
/dev/hda3           785       915   1052257+  83  Linux
/dev/hda4           916      2279  10956330    5  Extended
/dev/hda5           916       980    522081   82  Linux swap
/dev/hda6           981      1111   1052226   83  Linux
/dev/hda7          1112      1173    497983+  83  Linux
/dev/hda8          1174      1546   2996091   83  Linux
/dev/hda9          1547      1919   2996091   83  Linux
/dev/hda10         1920      2279   2891668+  83  Linux


I decided to install Woody, the testing distribution at the time of writing -- Potato is looking distinctly long in the tooth.  I downloaded the following components of Woody; you can get these from http://ftp.uk.debian.org/debian/dists/woody/main/disks-i386/current/images-1.44/ for example -- see http://www.debian.org/distrib/ftplist for a list of mirrors:

images-1.44/drivers.tgz
images-1.44/rescue.bin
images-1.44/root.bin


It's important that you put these files in a directory named images-1.44 -- the installation software expects that name.  I put them in /home/robin/woody/images-1.44/ and will assume that directory name in the commands that follow; substitute as necessary.  Next you need to extract a kernel from the rescue floppy so that you can boot it (you'll need to do the mount and the umount as root):

mount /home/robin/woody/images-1.44/rescue.bin /floppy -t msdos -o loop=/dev/loop0
cp /floppy/linux /home/robin/woody
umount /floppy


Now you can boot into the Debian installer from Grub.  Type the following three commands into the Grub command line (the Tab completion should reassure you that you have the right pathnames).  Note that Grub numbers partitions differently from Linux; (hd0,2) is /dev/hda3.

kernel (hd0,2)/home/robin/woody/linux
initrd (hd0,2)/home/robin/woody/images-1.44/root.bin
boot


You should boot into the Debian installer.  I didn't take copious notes at this point I'm afraid, as I was very aware I was on the final straight and was in a hurry to get done.  If I recall correctly I went to the second virtual terminal with C-A-F2, mounted /dev/hda3 ( not on /mnt! that will hose you big time!) and told the installer to find the Base files on a mounted directory.  I set up my partitions as follows:

# <file system> <mount point>   <type>  <options>                       <dump> <pass>
/dev/hda6       /               ext2    defaults,errors=remount-ro      0      1
/dev/hda7       /var            ext2    defaults                        0      1
/dev/hda8       /usr            ext2    defaults                        0      1
/dev/hda9       /usr/local      ext2    defaults                        0      1
/dev/hda10      /home           ext2    defaults                        0      1

/dev/hda5       none            swap    sw                              0      0
proc            /proc           proc    defaults                        0      0
usb             /proc/bus/usb   usbdevfs        defaults                0      0

/dev/hdc1       /flash          vfat    defaults,ro,user,noauto         0      0

# Foreign operating systems (Windows ME & Red Hat respectively)
/dev/hda1       /dos            vfat    defaults,ro,user,noauto         0      0
/dev/hda3       /redhat         ext2    defaults,ro,user,noauto         0      0


I installed the rest of the system off the network.  Take care not to install Lilo or otherwise touch the MBR.  I made an entry in Grub to boot Debian from the hard disk by editing /redhat/boot/grub/grub.conf as follows:

title Debian GNU/Linux (2.2.19)
        root (hd0,5)
        kernel /boot/vmlinuz-2.2.19 ro root=/dev/hda6


Note: the boot process depends upon /dev/hda3, the Redhat partition, where Grub looks for its configuration.  Don't nuke this partition without making alternative booting arrangements!  I'll sort this one out when I get everything working under Debian, and have no more need for Redhat.

PCMCIA and wireless

Having downloaded the 2.4.15 kernel I applied the patch to fix the inode corruption.  The kernel configuration I'm surrently using is here -- copy to /usr/src/linux/.config, "kernel-pkg --revision=s30.0 kernel_image" and install the resulting package.  I had a problem with the kernel not wanting to have both the Compact Flash and the PC card socket on IRQ11 (it put the PC card on IRQ 5, and inserting a card hung the box), so I removed the "continue;" from round about line 632 of /usr/src/linux/arch/i386/kernel/pci-irq.c and changed the message to indicate that the detected conflit was being ignored.  This seems to work, but I have yet to try using a Compact Flash card concurrently.  I also added entries for my wireless gateway, which is a Lucent RG1000, and an Orinoco Gold card.  The config changes I made (some of these may be superfluous... feedback welcome) are as follows:
/etc/pcmcia.conf
PCMCIA=yes
PCIC=i82365
PCIC_OPTS=irq_list=11,11
CORE_OPTS=
CARDMGR_OPTS=
/etc/pcmcia/config.opts
include port 0x100-0x4ff, port 0x800-0x8ff, port 0xc00-0xcff
include memory 0xc0000-0xfffff
include memory 0xa0000000-0xa0ffffff, memory 0x60000000-0x60ffffff
exclude irq 5
exclude port 0x230-0x233
exclude port 0x2f8-0x2ff
/etc/pcmcia/config (*after* other Lucent WaveLAN/IEEE entries)
card "Lucent Technologies Orinoco Adapter"
  manfid 0x0156, 0x0002
  bind "orinoco_cs"
/usr/src/linux/arch/i386/kernel/pci-irq.c
to allow sharing of IRQ11 by both socket 0 (Type II PC card) & socket 1 (Compact Flash card); diff starts about line no 632

                if (info->irq[pin].link == pirq) {
                        /* We refuse to override the dev->irq information. Give
a warning! */
                        if (dev2->irq && dev2->irq != irq) {
                                printk(KERN_INFO "IRQ routing conflict for %s, h
ave irq %d, want irq %d (ignored)\n",
                                       dev2->slot_name, dev2->irq, irq);
/*                              printk(KERN_INFO "IRQ routing conflict for %s, h
ave irq %d, want irq %d\n", */
/*                                     dev2->slot_name, dev2->irq, irq); */
/*                              continue; */
                        }
/etc/network/interfaces
iface eth1 inet static
  address 62.49.224.50
  netmask 255.255.255.248
  broadcast 62.49.224.55
  gateway 62.49.224.54
/etc/pcmcia/wireless.opts
# essid is 6-digit num. on rg1000, key is "s:" and last 5 digits of number
*,*,*,00:60:1D:*|*,*,*,00:02:2D:*)
    INFO="Wavelan IEEE Aglet gateway"
    ESSID="xxxxxx"
    MODE="Managed"
#    RATE="auto"
    KEY="s:xxxxx"
    POWER="on"
    ;;
/etc/pcmcia/wireless
added this to read POWER save option from wireless.opts
    if [ -n "$POWER" ]; then
        log $IWPATH/iwconfig $DEVICE power $POWER
    fi

With the wireless card inserted cardinfo looks like this (Figure 9); the network comes up automatically:

cardinfo, showing a wireless network card
Figure 9: cardinfo, showing a wireless network card

Interrupts and power saving

I've spotted trouble with interrupts, and it seems that it's still a problem.  Playing sounds works with ACPI, but not APM, and recording sounds with ACPI enabled hangs the machine.  This surely has to be because of interrupt conflicts, and may even have to do with the crude kernel patch detailed above, but I've not yet got round to debugging it.  Also ACPI Oopses when I try to get the battery status from /proc/acpi/battery/0/status.  This is less than ideal, as it means that it's not possible to tell how long the battery has left.  Mind you, APM always reported an estimate of 4000 minutes of remaining life, despite having a correct percentage.  The ACPI functionality included in 2.4.15 seems to be a) measurement of CPU temperature, via /proc/acpi/thermal/0/status, b) the power button initiates an "init 0", shutting the machine down, and c) closing the lid produces a message saying "the lid was closed", or words to that effect.  In the negative functionality department the Fn-keypresses for volume and the backlight brightness have stopped working, and there's still no suspend, hibernate or resume.  Here's a tiny script to show the CPU temperature in Celsius, rather than deciKelvins:
#! /bin/sh
TEMP=`sed -n '1 s/[^0-9]//gp' /proc/acpi/thermal/0/status`
dc -e "$TEMP 10/273.15-p"

Hints

Some random notes I've made whilst tweaking the machine: don't use framebuffer support; it doesn't work.  Similarly I found GPM to cause problems; who needs the mouse in the console anyway?  XFree86 needs XkbModel jp106 and XkbLayout jp in order to work right.  The USB floppy shows up under Linux as /dev/sda -- you'll need to build in SCSI support to use it, but don't bother with any SCSI drivers.  Mount usbdevfs with "mount -t usbdevfs usb /proc/bus/usb"; then you can use gphoto2 with digital cameras.  Get the "hotplug" package whilst you're at it -- see doc/gphoto2.txt.  Don't use kernel 2.5.0, and never eat anything larger than your head.  I've made a patch to xkeycaps to support the keyboard; Figure 10 shows a screenshot.
screenshot of xkeycaps, showing the s30 keyboard
Figure 10: screenshot of xkeycaps, showing the s30 keyboard

Here's a bare-bones guide to building and running the software with my mods:
cd /tmp
wget http://www.jwz.org/xkeycaps/xkeycaps-2.46.tar.Z
wget http://aglet.net/s30/tps30.tar.gz
tar zxf xkeycaps-2.46.tar.Z
tar zxf tps30.tar.gz
patch -p0 < tps30/all-kbds.h.patch
cp tps30/*.h xkeycaps-2.46/kbds/
cd xkeycaps-2.46
xmkmf
make
./xkeycaps -kbd TPs30

Wrap-up

I now have a triple-boot machine; a respectably-sized Windows ME install, suitable for Office and other Windows-specific stuff, a small (actually, it's cramped) RedHat install, which is going to be my guide to getting my hardware working under Debian, and a pretty decent sized Debian install.  Comments and additions to this document are more than welcome.  Also, if anyone reads Japanese I' d be grateful if you could let me know whether there are any BIOS updates for the s30; I expect the power management stuff is getting updated fairly frequently and would like to take advantage of support as soon as it appears.

Acknowledgements, etc.