Slackware on an IBM x40

Posted by: Andrew Smith
Poster contact info: andrew at littlesvr ca
Author: same as 'Posted by'
Software: Slackware 10.1

Well I got this nice laptop. It's called IBM x40 and it's sweet :)

Being so small it has no room for a CD drive but boy, it's got everything else.

Getting it to work was not a piece of cake but not a big pain either. It just takes a bit of dedication.

Summary
Managed to get to work:
- 1000Mb network card (didn't test at 1000Mb)
- framebuffer
- x11 with 3d
- sound
- PCMCIA
- power management
- trackpoint and the 3 buttons
- USB mouse
- USB Burner

Could not test:
- firewire port (i think that's what it is)
- infrared port
- docking station
- wireless card (don't have it)

Couldn't get working;
- external monitor (didn't really try)
- modem

Ok, let's begin with the beginning.

Booting
I got this machine with Windows XP Pro and without a docking station, no floppy or cd drive.

I needed to boot from something to install linux so I borrowed an external USB burner, set the bios to boot from it and put in my slackware disk.

Note that if you want to keep the windows that came with the ibm (on the recovery cds) you will have to stop here and think of what to do. I removed all traces of IBM supplied software and installed windows (as a second OS) from my own cd. There was an IBM recovery partition that I also deleted. Try looking at other guides, they may have more info about this.

It is hard to describe my surprise when I saw slackware not only boot from the USB drive but work perfectly all the way to the end of the installation.

Basic Slackware 10.1 install
Nothing really to say here other then 'it just works' :)

Booted with the default kernel, no parameters. CD drive was detected by the installer as /dev/sr0

I made a 10G / partition and a 15G /home leaving the rest for windows.

First thing I did after the slackware install was install the 2.6 kernel from the second CD. I never bothered with the 2.4 kernel but I can't think of anything that would not work with it (except CD burning).

Lilo
Don't know why lilo takes a good 15 seconds to load the kernel with the default settings. To fix this I uncommented compact from /etc/lilo.conf.

If you didn't select the framebuffer mode during installation, set it now. With framebuffer you will get full screen from boot. The LCD on this computer is a 1024x768 with max 16bit colour. The best framebuffer setting for this is vga = 791 which you only have to uncomment since it's already there.

As always, don't forget to run lilo after editing the config file.

ldconfig
You will notice that the two things that take a long time at boot (now that lilo is fixed) are ldconfig and hotplug. I don't see a reason to run ldconfig on boot. I asked around and noone else knows why it does. To save 10 seconds from every boot, comment out these lines from /etc/rc.d/rc.M:
#if [ -x /sbin/ldconfig ]; then
#  echo "Updating shared library links:  /sbin/ldconfig"
#  /sbin/ldconfig
#fi

Network Card
Works out of the box! Don't need to do a thing besides your regular network configuration (IP and such).

X
Run xorgconfig
Select ImPS/2 for your mouse type, type /dev/input/mice for the mouse device.

The video settings I guessed like this:

Monitor:
6  31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @ 60 Hz
800x600 @ 72 Hz
3  50-100


Video card:
15  ** Intel i810 (generic)               [i810]      -
5  4096K

Video mode:
16bitdefault:
 2  "640x480"
 3  "800x600"
 4  "1024x768"

You may notice later that the 4M of memory setting is not used. This video card uses the main RAM for video memory. You may also notice that the kernel module that gets loaded is i915 which is not what you selected here. But it works anyway.

Now start X to make sure it works. It should. Now exit and edit /etc/X11/xorg.conf to enable 3d acceleration.

It's the usual, uncomment these:
    Load       "glx"

    Load       "dri" 

Section "DRI"
    Mode 0666
EndSection
Go back to X and run glxgears from a console to make sure you get over 1000 fps. If you do, your 3d works and you can go ahead install QuakeIII.

To be able to use the trackpoint and a usb mouse at the same time you don't really have to do anything, just the regular modification to enable the scroll wheel on slackware. This is what my mouse section looks like:
    Identifier  "Mouse1"
    Driver      "mouse"
    Option "Protocol"    "IMPS/2"
    Option "Device"      "/dev/input/mice"
    Option "Buttons" "5"
    Option "ZAxisMapping" "4 5"

Switching video to the external monitor doesn't work. I so hear that you can install the i855crt program from http://sourceforge.net/projects/i855crt and it works but since it's a testing piece of software, I didn't try it yet.

Did you see what happens when you close and open the lid while X is running? Don't worry about it, we will fix that when we get to power management.

ACPI sensors
You need the ACPI sensor modules loaded to get ACPI :) and the power button to work. It's easy, just add this to your /etc/rc.d/rc.local:
echo "Starting ACPI sensors:"
echo "  battery"
/sbin/modprobe battery
echo "  button"
/sbin/modprobe button
echo "  ac"
/sbin/modprobe ac
echo "  fan"
/sbin/modprobe fan
echo "  thermal"
/sbin/modprobe thermal

You can run those commands now so you don't have to reboot.

Power button
Do yourself a favour and comment out everything in the file /etc/acpi/events/default because you will most likely get headaches trying to figure out why it doesn't work if you don't.

Create the file /etc/acpi/events/shutdown with these contents:
event=power
action=/sbin/halt
Remember you can only have one event per file.

Restart the acpi daemon with /etc/rc.d/rc.acpid restart. Now your power button should work. You have to hold it for about a second (not 3-5 seconds) for it to notice you :)

The action in the event file can be any command including a script of yours. Feel free to do fancy things when you shut down.

Suspend
You will need to edit your lilo.conf again. Otherwise the monitor will stay blank after you resume from suspend. Add the last line to your existing configuration:
image = /boot/vmlinuz-generic-2.6.10
  root = /dev/hda1
  initrd = /boot/initrd.gz
  label = Slackware-2.6
  read-only
  append="acpi_sleep=s3_bios"

Create a handler for the suspend event, the file /etc/acpi/events/standby with these contents:
event=sleep
action=/usr/local/sbin/acpistandby.sh

And the script /usr/local/sbin/acpistandby.sh with these contents:
echo "rmmod uhci_hcd"
rmmod uhci_hcd

# everything before this point is sleep
echo 3 > /proc/acpi/sleep
# everything after this point is wakeup

echo "modprobe uhci_hcd"
modprobe uhci_hcd

Make the script executable and restart the acpi daemon.

Notice that the USB modules are removed before suspend and reinserted after wake. This is needed because otherwise USB devices don't work after the machine wakes up.

Closing the lid
The top of the LCD screen looks all messed up when you close/open the laptop lid. It comes back to normal if you Ctrl+Alt+Fx to a console and back. I don't know why it happens but I do know how to fix it :) We will send the machine into a very light sleep any time the lid is closed. It will have to wake up from that sleep when you open the lid which I guess is the same as switching to a console and back. Poor explanation, I know.

Create the file /etc/acpi/events/blank with these contents:
event=lid
action=/usr/local/sbin/acpiblank.sh

And the script /usr/local/sbin/acpiblank.sh:
echo 1 > /proc/acpi/sleep

To send the machine into suspend you give ACPI a 3. The 1 just turns the display off or something stupid like that.

Sound
This was an adventure to set up. But don't worry, with this guide you will be dancing in no time :)

If you tried to get the sound to work before reading this, I bet you are getting this error from alsamixer:
no mixer elems found

Let's see. Do an lsmod | grep snd, you will see these two:
snd_intel8x0
snd_intel8x0m

Alsa is using the snd_intel8x0m and that's the audio device from the modem :) You don't want it or need it, so let's make sure it never bothers you again. Add to the end of /etc/hotplug/blacklist:
snd-intel8x0m

And .. khm .. reboot. Now run the usual detection and settings commands:
alsaconf
alsamixer
alsactl store

If alsamixer works but you are not getting any sound, that's because alsa set the output to go to the jacks instead of the speakers. Run alsamixer and mute (press 'm') these two channels:
Headphone Jack Sense
Line Jack Sense

Isn't this machine starting to look good? :)

ThinkPad Volume Buttons
There's a nice user-space application called tpb (thinkpad buttons). Get it from freshmeat. It has a dependency for xosd which you can also get from freshmeat. Both compile with configure && make && make install. I had no problems.

Tpb needs access to the nvram device. Edit your /etc/rc.d/rc.local and add this:
echo -n "Enabling ThinkPad Butons Display: "
modprobe nvram
sleep 1 # cause modprobe takes it's time :)
chmod 644 /dev/nvram
echo "done."

Edit your /usr/local/etc/tpbrc for some nice settings like the colour of the volume control. I set mine to green (windows guy :)

The one problem I have left with this is that tpb needs to be run after X loads. That means I cannot put it in my rc scripts. I tried the xinitrc script and that didn't work either. If you use Gnome or KDE, they both have the ability to start applications on logon, so just stick tpb -d into there. If you use XFCE like me you will have to find a better way or wait for XFCE to come with startup programs ability.

Conclusion
If everything worked for you as it did for me you now have a powerful laptop. Video good enough to play games on, sound to enjoy, super fast network, power management and USB mouse. For lack of resources, patience and skill I did not get everything to work. Perhaps you will. If you get any farther on this topic (Slackware on an x40) please post a reply to this guide. Thanks!

Now you can go show off with linux on your fancy laptop.

Cheers.

Slackware 10.2 ACPI

Posted by: Andrew Smith
Poster contact info: andrew-smith at mail ru
Author: same as 'Posted by'
Software: Slackware 10.2

Some changes happened to ACPI with the 2.6.13 kernel that comes with Slackware 10.2

You will have /proc/acpi/sleep missing. It has been 'deprecated in favour of /sys/power/state'

You will have to change the scripts described above.

New /etc/acpi/events/standby:
echo "rmmod uhci_hcd"
rmmod uhci_hcd

# everything before this point is sleep
echo mem > /sys/power/state
# everything after this point is wakeup

echo "modprobe uhci_hcd"
modprobe uhci_hcd

And new /etc/acpi/events/blank:
echo standby > /sys/power/state

Cheers

Slackware 12.0 ACPI

Posted by: Andrew Smith
Poster contact info: andrew-smith at mail ru
Author: same as 'Posted by'
Software: Slackware 12.0

In Slackware 12 the default kernel is vmlinuz-huge-smp-2.6.21.5-smp, which works well except it doesn't have a module built in that's required for ACPI sleep. I won't explain why cause honestly I don't understand myself - basically the reason is the 'smp' in that kernel.

If you only have one single core processor, this is easy to fix. The process is very similar to updating the kernel from 2.4 to 2.6 in previous Slackware versions.

Go into /boot and, as root, do the following sequence of commands:
ln -sf vmlinuz-generic-2.6.21.5 vmlinuz
ln -sf config-generic-2.6.21.5 config
ln -sf System.map-generic-2.6.21.5 System.map
mkinitrd -c -k 2.6.21.5 -m reiserfs

You can use System.map-huge-2.6.21.5 instead of vmlinuz-generic-2.6.21.5 if you like, and then you won't need to do the mkinitrd part.

If you do just copy paste those commands, you have to edit /etc/lilo.conf and add the line initrd = /boot/initrd.gz to your boot settings, so it looks like this:
image = /boot/vmlinuz
  initrd = /boot/initrd.gz
  root = /dev/hda1
  label = Slackware
  read-only  # Partitions should be mounted read-only for checking
  append="acpi_sleep=s3_bios"

Other than that Slackware 12 is pretty much the same as the previous versions. The differences good to know are: you no longer need to rmmod uhci_hcd when going to sleep, you don't need to echo 1 > /proc/acpi/sleep when closing the lid, and the sound works out of the box.

Enjoy.

Slackware 12.2 Sleep

Posted by: Andrew Smith
Poster contact info: andrew-smith at mail ru
Author: same as 'Posted by'
Software: Slackware 12.2

Oh, bother - this will never end :)

The new kernel in the new Slackware has yet again a different way to configure ACPI. First, edit /etc/rc.d/rc.acpid and enable logging, by appending -l to this line:
    /usr/sbin/acpid -l

This will allow you to see acpi events in /var/log/messages when you press butons.

The instructions for the power button are the same as the original ones, but for sleep (Fn+F4) you have to change the event. New /etc/acpi/events/standby:
event=ibm/hotkey HKEY 00000080 00001004
action=/usr/local/sbin/acpistandby.sh

And the script /usr/local/sbin/acpistandby.sh:
# everything before this point is sleep
echo mem > /sys/power/state
# everything after this point is wakeup

Note that removing the usb modules isn't needed any more.