Linux Column March 2000


[ Site Index] [ Linux Index] [ Feedback ]


Fun with laptops

Once a year -- or more often, if I can grit my teeth and stretch it a bit further -- I buy myself a new computer.

Actually, buying a computer isn't a rare event for me. (I collect old orphaned machines; there's an ICL One Per Desk -- in need of a new power supply -- sitting on top of the two VAXstations gathering dust in my study right now, and yesterday someone deposited an orphaned PDP-11/53 behind the cat's litter tray.) What makes the event rare is me buying a *new* computer, because it hurts; unlike the golden oldies, new kit costs more than the odd pint, and dies of old age faster than a flowering plant left in my care. (And that's really saying something: I have paraquat fingers.) Nevertheless, buying new kit on a regular basis is compulsory; even though Linux will run happily on elderly machines, trying to crank it up on an Amstrad PC1512 is a losing proposition. And you wouldn't want to read about it more than one month in a row, anyway.

Which is why a month ago I gritted my teeth, mugged the piggy-bank, and splurged out on a new laptop.

Laptops have come on a long way since my first -- a Zenith MiniSport, in 1990. The MiniSport had two 720K floppy drives, one of them in a weird 2.5" form factor. It had a monochrome CGA screen,320x400 pixels. The processor was an 8Mhz 8086, and it had a whopping 2Mb of memory in which to run DOS. My new machine weighs less, has a 1024x768 pixel screen, a 6Gb hard disk, 366MHz processor, and 128Mb of RAM. It cost about the same, too. In fact, it has about twice the screen real estate, twice the memory, twice the CPU horsepower, and triple the disk space of its immediate predecessor, which also cost the same. (I don't know whether to laugh or cry, sometimes; if it wasn't for Moore's Law -- which dictates that computers double in power roughly every 18 months -- I'd be spending a lot less money. On the other hand, I'd probably not be earning as much. Ho hum.)

That first laptop wouldn't run Linux, or anything UNIX-like; no way. My last laptop, though, was quite capable of running Red Hat 6.0: the new one doesn't even chug when loading up StarOffice and Netscape on top of GNOME and Enlightenment.

However, the march of progress is not irresistable. Installing Linux on a laptop is a bit trickier than you might imagine. While most distributions have a set of pre-canned configurations you can install, none of them cater specifically to laptops; in fact, some are positively hostile to the very concept.

strange chips

The first obstacle to installing Linux on a laptop is the level of hardware integration laptops typically incur. Desktop PC's are modular; you can whip out anything from the motherboard to the display card and drop in a different but functionally equivalent replacement in the sure knowledge that it'll work. Laptops don't have room for potloads of PCI bus slots and cables; they're tightly integrated, and the manufacturers tend to buy in special purpose chipsets optimized for low power consumption to do things like drive the LCD display and sound subsystems.

The reason this can be a problem is that the chipset providers often neglect to publish details of their products. Unlike a VGA display card, which could end up inside just about anything, a Chips and Technology 65550 display controller chip will only end up inside a laptop built by a C&T customer OEM. So only the OEMs get to see the details of the chipset. (The desktop graphics cards, in contrast, are much more likely to have published documentation available. There are exceptions, but this is a general rule.)

If you're planning on buying a laptop to run Linux, it is a bad idea to buy something that's too close to the bleeding edge. You might be able to whip the video adapter out of your desktop PC and stick an old Matrox Millennium in it until the XFree86 project catches up, but you can't do that to a laptop. If the video chipset isn't supported and the manufacturer isn't keen on disclosing details to Linux developers -- some, like NeoMagic, seem to positively revel in saying no -- you will be stuck, at least for a while.

One possibility if you're saddled with such a machine is to buy a copy of Xi Graphics' Accelerated-X X server. Accelerated-X is a commercial X display server. The reason Xi Graphics are still in business, despite the existence of the excellent XFree86 X server (which is free) is that they fill a niche market. Accelerated-X Laptop Display Server specialises in supporting bleeding edge laptop chipsets (albeit at a price). Xi Graphics -- unlike the XFree86 project -- can pay money for an OEM license or sign non-disclosure agreements. They can also pay talented engineers to work full-time reverse engineering some obtuse new controller. The result is a product that most people don't need -- but if you happen to have bought a bleeding-edge laptop and X simply doesn't run on it, www.xig.com is the place to go.

(An X server that supports weird hardware isn't all you get from Accelerated-X, of course. It also comes with some fairly sophisticated gamma correction and colour temperature controls, TrueType font engine, and a few other goodies. Again, if you need colour temperature callibration, you probably need it badly enough to make the price worth-while.)

Another possibility is to check Red Hat's XBF program. Red Hat (you don't need their URL, do you?) do their best to pursuade vendors to release details for free -- but if they won't, Red Hat will sign the necessary NDA's and then release a free binary-only X server. SuSE run a similar project; while they aren't as close to the edge as Accelerated-X, they're also helpful to know about. For example, this laptop (a Sony PCG-F304) has a NeoMagic display controller; it's running an XFree86 server, but its predecessor started out on an XBF server (before NeoMagic released details to the XFree86 project).

Similar provisos apply to sound support. Some laptops have sound chips that emulate a SoundBlaster board -- but some don't. Again, this Sony laptop has a weird NeoMagic sound chip (it uses a spare chunk of the video memory as an audio buffer!) that is simply unsupported by the Linux open sound system. OSS, the commercial sound driver people (aka 4front Technologies) have promised support for it in the near future; meanwhile the only working option is a weird kernel patch that requires a working knowledge of kernel configuration to install (about which more later).

Extras

Beyond screen and sound, Laptops have extras that tend to preoccupy their owners -- extras that desktop computers simply don't have. There's APM, advanced power management -- used to control power consumption and monitor your battery performance. There're PCMCIA cards for modem or network connections, and because they're hot-swappable they don't behave like their equivalents in a desktop system. Most laptops these days also have IRDA ports for infra-red networking or printing. They almost certainly have a different type of pointing device from your desktop machine. And laptop owners need to think hard about configuring their machines to minimize power consumption, if running off battery -- Linux, like all UNIXes, tends to hit the hard drive quite hard, for example.

Weirdly, none of the distributions I've seen seem to come with a "laptop" installation package. Some of them are really bad at laptop support; for example, Caldera 2.3's kernel is compiled without APM support (essential if you want to be able to put your machine to sleep or see how much juice is left in the battery). Others are merely negligent. By default, almost all distributions install the cron daemon (to handle timed execution of background jobs). Cron tends to hit the hard disk every sixty seconds to see if it has anything to do! And the kernel daemon -- which flushes dirty buffers from the cache back to disk -- normally runs every minute. While this isn't a problem for a desktop machine with a continuously spinning disk, a hard disk eats laptop battery life; you can set a short inactivity timeout with hdparam (so that the disk spins down after, say, 20 seconds of inactivity), but this is not much use if the kernel daemon hits it once a minute.

IRdA support isn't something most desktop users are concerned with. Linux (as of kernel 2.2) supports IRdA, with a variety of options; you can configure your IRdA port to look like a serial port (as far as Linux is concerned), or you can configure it as a network device for TCP/IP. You can also use the IRdA printing protocols and data exchange protocols with a bit of work. But most stock kernels simply don't come with IRdA support built-in, or available as modules, because most desktop PC's simply don't have IRdA ports.

PCMCIA support isn't even part of the standard kernel distribution yet -- it comes as an installable kit that builds kernel modules on top of the rest of the system. (At least until 2.4 is released, at which point PCMCIA support should be present as standard.) More of the Linux distributions support PCMCIA devices, as it is impossible to install Linux on some laptops without it (for example, to access a network card or PCMCIA-driven CDROM drive), but if you want to build a kernel with APM or IRdA support you'll also need to re-build the PCMCIA modules.

Going about it

So, given that laptops are so non-standard, how do I go about getting Linux working on a new one?

The first step is the Linux on Laptops website (you can find a UK mirror site at http://physics.open.ac.uk/~rpblake/linux_laptop/). This is the home of the Linux Laptop HOWTO, an invaluable document that is several times the length of this article and crammed full of useful information. It's also the clearingpoint for links to monographs describing specific models of laptop. Most of these follow a standard format and explain how to get a basic Linux system up and running, and then how to enable support for various devices.

Don't worry if the laptop of your dreams isn't listed.Many manufacturers churn model numbers like crazy, changing the digits to indicate they've just upped the size of hard drive they're installing as standard. It may well be that an earlier but nearly identical machine is listed.

You're more likely to find a detailed monograph on some well-known machine -- Toshiba, HP, Dell, IBM, Sony. (No-name brands are a headache; unless it's rebadged by someone famous under their own name, you probably won't find much information about them.)

It's probably not a good idea to buy a cutting-edge machine that's only just been introduced. While getting a minimal Linux system running on it may not be difficult, you may find that it has a new (and unsupported) video system, and access to all its facilities is difficult. (For example, this Sony Vaio PCG-F304 has a FireWire port that isn't exactly usable right now, unless you're willing to experiment with development kernels and beta drivers.)

Remember that laptops usually don't come with enough RAM, any more than desktop PC's do. They also tend to be more costly to expand. If you're spending a couple of thousand pounds on a machine, it doesn't make sense to skimp on a two hundred pound upgrade that will remove a critical performance bottleneck. It's also a good idea to ask for a manufacturer's data sheet before you buy one; look for items like the type of display controller chip. (We're not talking glossy marketing pamphlets here.)

The next stop is to repartition the hard disk and install Linux. It is probably a bad idea to completely nuke Windows (which almost inevitably comes preinstalled on all laptops); you may want to use it to look up details of the machine's configuration. It's also a bad idea to trash small partitions near the end of the hard disk -- some laptops save their memory contents to disk when hibernating, and if you trash the memory backup partition you won't be able to do this. Using a tool like FIPS to shrink the Windows partition size is probably the best option -- or Caldera 2.3 (despite the lack of APM support out of the box), which comes with Partition Magic.

A laptop with Linux installed isn't necessarily functional. The next step is probably to get X working. This may happen automatically -- almost all Linux distributions today try to configure X for you -- but if it doesn't you may have to do some research on the web. (I did warn you not to trash Windows straight away, didn't I?) First stop is www.xfree86.org, where you may be able to figure out if (or when) your video chipset is supported by XFree86. Next, you may need to do a web search (via something like Google) for your video chipset and Linux -- see what it throws up by way of detail. It's also worth checking Red Hat's XBF project and SuSE's web site for their custom X servers.

If those resources don't give you something that will run on your display, you may want to investigate Accelerated-X's laptop display servers, or Metro-X (another commercial X server product). Both these companies sometimes support chipsets which aren't available to the non-commercial project yet. Note, however, that this is changing fast -- for example, NVidia's latest high-end graphics boards are coming out with Linux support from the manufacturer, and this example can only spread.

After getting X working (an odyssey in its own right!), the next stop is probably PCMCIA support. You may be lucky; Red Hat ships a kernel with PCMCIA support, as do other vendors. Linux PCMCIA support is not cutting edge; however standard items should work. Cardbus or ZV support is dodgy or absent; sound cards are unsupported: but ethernet cards, modems, and some SCSI controllers are available. I'm writing this on a laptop with a 3Com Etherlink-III combi card (modem and ethernet), and an Adaptec-1460 SCSI controller card. Before using PCMCIA devices you really should read the PCMCIA-HOWTO; they don't work the way standard (non-removable) PCI or ISA cards work, and you can screw things up royally by assuming that they're hot-swappable or read the same configuration files as anything else. Also, if you rebuild your kernel you will need to recompile PCMCIA support afterwards -- it's a separate package.

Next on the hit list is APM. Support for this needs to be compiled into your kernel. There's a useful APM daemon (apmd) that can be configured to monitor your battery level and do things like put your laptop to sleep when it gets critically low; there are also various battery monitors for X, and the GNOME and KDE environments. Beware, though. APM BIOS's are notorious for being unpredictably buggy. This Vaio had a nasty habit of freezing solid the second time I put it to sleep; this turned out to be due to a weird interaction with the USB controller, of all things (and is common to some, but not all, other F-series Vaios). And, as noted, Caldera 2.3 doesn't have APM support in the kernel.

You may or may not want to experiment with IRdA -- it probably depends on whether or not you have any other devices with infra red ports. (I should confess at this point that I haven't played with IRdA yet; expect to read about it in a future column.) Again, this will probably be another "recompile the kernel" experience. (By now you'll be getting intimate with "make xconfig".)

Once you've got the basics sorted out -- X, PCMCIA cards, APM, any other specialised hardware -- it's time to tune your laptop for maximum battery life. When using a laptop, it makes sense to compile as many kernel features as possible as loadable modules rather than building them into the kernel. (Modules can be unloaded and reloaded creatively, for example if they tend to cause problems when you put your machine to sleep.) In addition to switching on APM support, enabling your kernel to make CPU idle calls when idle is a good idea; this can cut power consumption nicely. It's also probably a good idea to unload PCMCIA cards when they're not in use, at least on battery power: it's surprising how much power they suck.

In routine use on battery power, it's a good idea to minimize disk accesses and use hdparm to enable automatic spin-down of your hard disk. This and many other useful tips are detailed in the "Battery-Powered" mini-HOWTO which discusses power saving techniques such as disabling cron, adjusting the frequently with which the kernel flushes buffers to disk, and adding a "sleep" command to your /etc/innitab file (that can be triggered by hitting CTRL-ALT-DELETE or some other key combination).

Finally, though, the best piece of advice I can think of for anyone using a laptop -- whatever they're running -- is quite simple and quite universal: get a good case! Get a case with plenty of padding and, if possible, hard shell protection for the screen: because however much damage you can do with a buggy software installation, it's as nothing compared to what you can do by accidentally dropping it or sitting on the lid. And try to get a case that doesn't scream "I am an expensive laptop!" at two hundred decibels, because an unattended laptop in a public place has the life expectancy of a week-old yoghurt in a heat wave (at least as far as its rightful owner is concerned).


[ Site Index] [ Linux Index] [ Feedback ]