Polishing Your Linux Laptop Setup
In my past laptop oriented articles, I talked about procedures for installing a base Linux system and setting up GNOME 2.2. This time around, I discuss a few odds and ends that did not quite fit those other two articles but definitely deserve further attention.
Wireless networking is an integral advantage to laptop computing. In my situation, I never would have gotten involved with Linux on laptops if wireless networking had not become available. There's nothing quite like browsing the Web from your favorite chair with a cold beverage nearby, the way all computing should be done. For this example, I'm going to set up a Lucent Orinoco 802.11b PCMCIA card. There are many new and old standards in the wireless world, but from what I have seen 802.11b is by far the most popular. Also, you may find it necessary to implement different layers of security if you live in a populated area. Plenty of articles already are written that discuss the complicated world of WiFi security, so I'm not going to dabble in that arena. If you'd like to learn more about WiFi security, check out the Resources at the end of this article, and your questions will be answered.
As with most network device installs, the first thing you need to do is make sure the kernel module or modules are installed for the hardware in question. In the case of the Orinoco, you should have set the following options in your kernel configuration under Network device support. If you have not set these options, you now need to recompile and reinstall the kernel.
Selected - Wireless LAN (non-hamradio)
Module - Hermes chipset 802.11b support (Orinoco/Prism2/Symbol)
Module - Hermes PCMCIA card support
In my case, I also had to enable ISA Bus support for the 16 bit PCMCIA card. This is done under General setup, and the option is [*] ISA bus support. As far as I can tell, this option is new to the 2.4.20 kernel. After reading through many newsgroups and Web searches, it looks like a lot of people have problems with Orinoco cards after upgrading to the 2.4.20 kernel. So make sure that you enable ISA Bus support.
With the kernel modifications complete, the next task is to install the Debian packages needed to access a PCMCIA card. A quick apt-get install wireless-tools and apt-get install pcmcia-cs should grab everything you require. All of the configuration files for PCMCIA can be found in the /etc/pcmcia directory. The three files that need to be manipulated are config, network.opts and wireless.opts.
Let's start by editing the config file. Scroll down to the device orinoco_cs section, and make sure it looks like the following. If any other lines are present in the device "orinoco_cs" section, comment them out.
device "orinoco_cs" class "network" module "hermes", "orinoco", "orinoco_cs"
Next, open up network.opts and alter the TCP/IP values beneath the line # Host's IP address, netmask, network address, broadcast address. These values are the same as if you were configuring a traditional TCP/IP network card. Some may be left null or filled in as needed. As an example, here are the values I used to configure to my local LAN:
IPADDR="192.168.1.4" NETWORK="192.168.1.0" BROADCAST="192.168.1.255" GATEWAY="192.168.1.1" DNS_1="192.168.9.47" DNS_2="192.168.9.48"
Then, open wireless.opts, which contains many options specific to the wireless connection. To simplify my example, I am not going to use any security options. This is not recommended if you live in an urban area, but if you're out in the boonies, I don't think there is anything wrong with letting the local raccoon population get some free Internet access. The only things that need to be changed are two ESSID settings. One of them is under the section commented by Lucent Wavelan IEEE and the other is under Generic example. Under both of these sections, change the ESSID value to any, so it looks like ESSID="any".
If you haven't rebooted yet, now would be a good time to do so, to make sure the PCMCIA services are brought up correctly. During boot you should see something like the following output. If the boot messages scroll too fast, you can check in /var/log/syslog.
cardmgr: watching 1 sockets cardmgr: starting, version is 3.2.2
Once the machine is booted, use tail -f /var/log/syslog to watch the syslog and insert the Orinoco card. If things are set up correctly, you should see something in the log like the following:
cardmgr: socket 0: Lucent Technologies WaveLAN/IEEE Adapter kernel: cs: memory probe 0xa0000000-0xa0ffffff: clean. cardmgr: executing: 'modprobe hermes' kernel: hermes.c: 5 Apr 2002 David Gibson <email@example.com> cardmgr: executing: 'modprobe orinoco' kernel: orinoco.c 0.11b (David Gibson <firstname.lastname@example.org> and others) cardmgr: executing: 'modprobe orinoco_cs' kernel: orinoco_cs.c 0.11b (David Gibson <email@example.com> and others) kernel: eth1: Station identity 001f:0001:0008:0048 kernel: eth1: Looks like a Lucent/Agere firmware version 8.72 kernel: eth1: Ad-hoc demo mode supported kernel: eth1: IEEE standard IBSS ad-hoc mode supported kernel: eth1: WEP supported, 104-bit key kernel: eth1: MAC address 00:02:2D:3A:35:08 kernel: eth1: Station name "HERMES I" kernel: eth1: ready kernel: eth1: index 0x01: Vcc 5.0, irq 3, io 0x0100-0x013f cardmgr: executing: './network start eth1'
When you remove the card you should see
cardmgr: executing: './network stop eth1' cardmgr: executing: 'modprobe -r orinoco_cs' cardmgr: executing: 'modprobe -r orinoco' cardmgr: executing: 'modprobe -r hermes'
At this point you should have a fully functional wireless laptop. The Orinoco card can be removed and inserted as required without a need to reboot or to configure any further. If you have problems, one useful command for troubleshooting PCMCIA issues is cardctl. Using cardctl, you can verify that your card is what you think it is. You also can gather information on the state of the PC card slot in your laptop.
Here's one little trick I'm using. In my case I use my laptop at two primary locations, work and home. When I'm home I use the WiFi card and when I'm at work I use the integrated NIC. At work I have no issues, because I keep the WiFi unplugged so the device is never brought up. But at home, I had a problem: when I used WiFi I had to manually down the integrated NIC, because some applications did not like eth0 being up but not connected to anything. It was not a major issue, but it got to be an annoyance to have to manually ifconfig down eth0 every time I booted the laptop at home. What I did to correct this problem was add the following line to the end of /etc/pcmcia/wireless:
ifconfig eth0 down
This script is executed only when the wireless device is brought up, so it works perfectly. Whenever I insert the Orinoco card, the integrated NIC is disabled.
The ALSA project supports a wide variety of sound cards and chipsets under one common package set. This design makes it much easier for the end user, because they do not have to look far for a valid install procedure or for other ALSA users to assist with issues that may arise. A testament to the overall value of the ALSA project is its planned integration into future kernel releases. For now, though, we have to compile and install manually ALSA's modules.
Rather than replicate the install documents that already exist, I'm going to provide a brief overview of the install process and point out some areas where I varied from the install docs. Before you start installing ALSA, make sure your kernel is enabled to use soundcore support. The soundcore option is selected by choosing Sound card support during the kernel config process.
Selected - Sound card support
The first part of the install process is typical of any Linux source install, using the standard ./configure, make and make install steps. You have to follow these three steps for each of the three packages that make up the ALSA sound suite: alsa-driver , alsa-libs and alsa-utils.
Next, you have to create and add some lines to /etc/modutils/alsa. Rather than create a new file, I added these lines to the bottom of /etc/modutils/aliases. The lines they suggest you use are:
# ALSA portion alias char-major-116 snd alias snd-card-0 snd-intel8x0 # module options should go here # OSS/Free portion alias char-major-14 soundcore alias sound-slot-0 snd-card-0 # card #1 alias sound-service-0-0 snd-mixer-oss alias sound-service-0-1 snd-seq-oss alias sound-service-0-3 snd-pcm-oss alias sound-service-0-8 snd-seq-oss alias sound-service-0-12 snd-pcm-oss
In addition, I also added a few off lines to stop some annoying error messages that would show themselves during boot. So for my Intel810 chipset, I added the following lines to the bottom of my /etc/modutils/aliases file.
# ALSA portion alias char-major-116 snd alias snd-card-0 snd-intel8x0 alias snd-card-1 off alias snd-card-2 off alias snd-card-3 off # module options should go here # OSS/Free portion alias char-major-14 soundcore alias sound-slot-0 snd-card-0 # card #1 alias sound-service-0-0 snd-mixer-oss alias sound-service-0-1 snd-seq-oss alias sound-service-0-3 snd-pcm-oss alias sound-service-0-8 snd-seq-oss alias sound-service-0-12 snd-pcm-oss
After you finish changing the aliases or alsa file, you must run the command update-modules to make your alterations final.
Putting start/stop scripts in place also is a good idea. These scripts save your volume settings so the previous volume settings are restored after a reboot. The primary start/stop script already exists in /etc/init.d; you simply have to create some links:.
ln -s /etc/init.d/alsasound /etc/rcS.d/S80alsavolume ln -s /etc/init.d/alsasound /etc/rc0.d/K02alsavolume ln -s /etc/init.d/alsasound /etc/rc6.d/K02alsavolume
At this point, you should be ready to start using ALSA sound. It's a good idea to reboot to make sure all your start scripts are working properly and the modules are loading up correctly. In GNOME, you can configure all the system sounds through the Sound control panel, which can be found on the Desktop preferences menu.
ACPI, which stands for advanced configuration and power interface, is a power management component eventually set to replace APM. The current state of ACPI as a whole is marred at best. Laptop manufacturers often deviate from following any type of standard when coding certain ACPI-related BIOSes and components. Rather than follow a standard, they rely on proprietary Windows drivers to keep things functioning. Unfortunately, in many cases, this leaves Linux users out in the dark.
When ACPI is in place and running 100% correctly, there are many advantages to its use. It can monitor power-related components, such as the AC adapter and battery. One of its advanced features involves processor re-clocking abilities. You can configure ACPI to drop your CPU frequency when the laptop is idle. It also can control the system's fans, adding another layer of monitoring in regards thermal protection. Another, more broad feature is the ability to monitor certain events that take place on your laptop. Closing the lid or pressing the power button can be configured to send the laptop into a sleep or suspend state.
I'm not going to lie to you, ACPI can be a beast to setup. Don't attempt to get ACPI running unless you are comfortable altering the kernel. The steps are not necessarily complicated, but if you make an error, you could hose up the kernel pretty seriously and have to boot from an alternate kernel to repair the damage. From what I've seen, a vast majority of laptops are not fully ACPI compliant. Of course, there are exceptions to the rule, but a quick web search shows users of all laptop manufacturers have problems with ACPI. This does not mean that ACPI is useless to a Linux user; even in its impaired state, it can offer more functionality than APM. And many tweaks and patches are available to help you get it running. Finding the sources for these tweaks and patches for your specific laptop can be another battle altogether.
Here are some steps to follow, assuming you laptop is somewhat ACPI compliant. I'm working with the 2.4 kernel for this example. The 2.5 kernel has the ACPI modules integrated, but for the sake of a larger audience I'm going to use 2.4.
First, you need to put the Linux kernel source in order. In a previous article, I worked with the 2.4.20 source found in Debian's Sid package repository. Although this source works fine, I have had problems getting the ACPI patch to apply to it. To avoid any of these complications, download the 2.4.20 source from www.kernel.org. Once you've downloaded the source, uncompress it in your /usr/src directory. Then cd into /usr/src, and link linux to the 2.4.20 source with ln -s linux-2.4.20 linux.
After the kernel source has been downloaded and linked, you can get the ACPI patch from sourceforge.net/projects/acpi. It is important to use the patch that coincides with your kernel revision. Move the patch into the /usr/src/linux/ directory and uncompress it. At this point, you should have a acpi-something.diff file within the /usr/src/linux directory. This is the file you will use to patch the kernel with support for ACPI. Run the following command from inside the /usr/src/linux" directory to commit the patch. In this example, I'm applying the latest 2.4.20 ACPI patch.
patch -p1 < acpi-20021212-2.4.20.diff
After the patch has been applied, run make menuconfig and configure the kernel. This time, however, notice the submenu for ACPI Support under the General setup menu. This is where you choose which ACPI options you would like to use. If this is your first time using ACPI on the laptop, it can be a crapshoot figuring out which features will be supported. A couple important things to remember during this step are to enable Power Management support but not Advanced Power Management BIOS support. ACPI does not function correctly with APM enabled, but Power Management support must be enabled for certain ACPI features to work.
Once the kernel source has been configured to your liking, compile it, install it, reboot and prepare for some intense ACPI action. After the machine has booted, log in to a root console and run dmesg |more. If the ACPI module is having any problems, they will show up here. dmesg also is a good tool to use to find out specifics on how extensively your laptop supports different ACPI features.
If you are lucky, dmesg shows ACPI coming up with no issues. I ran into a problem with ECDT on my Thinkpad R32, however. After extensive troubleshooting, I discovered that a bug in the Thinkpad's ECDT prevents ACPI from coming up. Fortunately, someone has written a HOWTO on getting the kernel to work with the buggy ECDT. It can be found here.
In its current state, ACPI is buggy at best. Until laptop manufacturers iron out some kind of standard, I fear ACPI is going to be a thorn in every Linux user's side. If APM is functioning correctly on your laptop or if you do not have tons of extra time on your hands to troubleshoot, I would not recommend using ACPI. Hopefully, ACPI support will get better and better with each new laptop model released. With any luck, in a year or so ACPI Linux support will be as non-combative as APM support has become.
There is no way any Linux user could get anything done without the community's support. In the course of writing these Linux laptop articles, I have read countless articles and HOWTOs on the topic to further my knowledge in the area. Here are some of the more applicable sites I have come across.
ACPI: Sourceforge hosted project home of the ACPI 2.4.* patch.
atitvout: atitvout is a way to use the svideo out on ATI sound cards. Works great on my R32's Radeon 7500.
Advanced Linux Sound Architecture: the home page of the ALSA project.
GNOME Support: a great resource if you need help with GNOME. I recommend browsing the forum.
Linux Compatible: a good site for researching the compatibilities of a Linux laptop's components.
Linux on Laptops: perhaps the most definitive resource for laptop setup research.
TPB, ThinkPad Buttons: home page for the TBP Thinkpad utility for using the nvram-based volume and Thinkpad keys.
TuxMobil: similar to Linux on Laptops but not quite as many laptop installs to look through.