Ask Klaus!


Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

Understanding Hardware Detection

Question:

Hello Klaus! I have read so much about how amazing Knoppix's hardware detection is and that you created it. I would really like to understand how hardware detection and configuration works for a Live CD or installed system: what process it goes through and how it's all put together.

I would really appreciate, since you are so knowledgeable in this area, if you could guide me toward the resources I would need to understand and learn all of this. Thank for your time and for a great distribution, Knoppix! Dakota Clark

Answer:

Hardware detection and support has changed a lot since the first Knoppix versions. In the earliest version, it was a mix between loading the "most commonly used hardware drivers" and a program (hwsetup) written in C that scanned the system for known hardware, loaded the corresponding drivers, and created configuration files for various hardware-related services.

Currently, udev, as a standard system service, is used for loading the correct drivers instead of the C program, and scripts create config files and entries for filesystems. It's a little easier for me now, although it is still necessary to check for exceptions when "bad" hardware is encountered and to do some workarounds for common problems.

You can have a look at most of Knoppix's boot process and hardware detection when browsing through /etc/init.d/knoppix-autoconfig and /usr/sbin/{scanpartitions,rebuidlfstab}. Some of it is just preconfiguration of system settings in a convenient way that differs from Debian's defaults. I try to avoid doing everything differently, so my boot scheme does not touch Debian's owb. It is simply run instead and can be reverted after hard disk installation to go back to the standard boot scheme.

Notebook Hotkeys and ACPI

Question:

I just bought a brand new notebook but noticed that the hotkeys (FN+F1 ... F12), which are supposed to change brightness settings and loudness, don't work. Do I need a special driver for these to work?

Answer:

Usually, you don't. The kernels delivered with current distributions already contain the special hotkey drivers for most brands of notebooks. However, it may depend on the BIOS and ACPI handling of the notebook, because there is more behind hotkeys than just drivers.

It works this way:

1. Once you press a special notebook key, an ACPI event is generated.

2. The acpid service under Linux evaluates the event code number.

3. Then, the service starts a script associated to this event.

So, you can see there are actually three things that can go wrong. It's possible that the ACPI event is not created, which would indeed be a "driver" problem. To start, you should check whether acpid is running. If it's not, do:

sudo /etc/init.d/acpid start

Then, check whether the key is generating an ACPI event. Start

acpi_listen

which will wait for and display acpi-handled keystrokes. If you press the hotkey combinations, acpi_listen should print something like this:

hotkey ATKD 00000037 00000010
hotkey ATKD 00000038 00000003
hotkey ATKD 00000026 0000000f
hotkey ATKD 00000027 0000000e
?

If nothing appears, the hotkeys are not handled by ACPI, which could occur for several reasons. Some notebooks handle hotkeys internally without creating ACPI events, so brightness or volume actually change but with no visible feedback. Some notebooks change their behavior when you specify the operating system for ACPI, by adding a kernel boot option.

linux acpi_osi=Linux
linux acpi_osi=!Linux
linux acpi_osi="!Windows 2009"

You can set these via boot command line and, if any of them work, add them into /boot/grub/menu.lst or /etc/lilo.conf in the KERNEL and APPEND line, respectively, as options.

On a new Eee PC 1101HA and Linux kernel 2.6.33, without the acpi_osi option, the powersave modes and battery-capacity display worked, but hotkeys didn't. acpi_osi=Linux made the hotkeys work, but the battery-capacity display was broken, and cpu-frequency scaling didn't work either. I succeeded in getting everything to work with the acpi_osi="!Windows 2009" option (note that you need double-quotes for options that use whitespace).

If you need acpi=off to work around interrupt problems for your notebook, likely the hotkeys will not work at all, or only the APM powersave ones will work.

As soon as acpi_listen displays hotkey events correctly, you can check whether they are evaluated correctly. Make sure that the acpi, acpid, and acpi-support-base packages are installed. For some notebooks, special preconfigured packages are available that handle the hotkeys, such as eeepc-acpi-scripts for the Eee PC 70x and 90x models.

The ACPI daemon acpid looks for ACPI eventcodes in /etc/acpi/events; here is an example for the hotkeys:

knopper@eeepc:~$ cat /etc/acpi/events/hotkey
event=hotkey ATKD
action=/etc/acpi/actions/hotkey.sh %e

So, the script /etc/acpi/actions/hotkey.sh actually evaluates the ACPI event code and decides which actions are taken. For notebooks that handle brightness settings internally, this script just displays an on-screen message. For the Eee PC 1101, I have to set brightness explicitly, as in this excerpt from my /etc/acpi/eventsactions/hotkey.sh (Listing 1). With this add-on, the ACPI hotkeys for brightness work by explicitly setting the backlight intensity and displaying a message, but this example is very specific to this special notebook.

Listing 1: Explicitly Set Brightness
01 # Fn+F5 -- decrease brightness on eeePC 1101HA
02 # Fn+F6 -- increase brightness
03 # The last digit of $code actually is a number 0 ... 15 in hex,
04 # which supposedly means the desired brightness.
05 case "$code" in 0000002*)
06         num=${code#0000002}           # get last digit
07         num=$(printf "%d" 0x$num)     # now in decimal
08         let percent=$num*100/15       # Calculate percent
09         echo  $percent > /sys/devices/*/*/backlight/*/brightness  # set it
10         notify "Brightness" $percent  # Show OSD message
11         ;;
12 esac

Returning Windows

Question:

I just bought a brand new notebook with Windows 7 preinstalled, but I want to run it on Linux exclusively. Do you know if I can return the unused operating system and get some money back?

Answer:

In fact, it is possible, though not always easy and straightforward. The Windows license allows you to return the operating system unused and unopened - for example, if you feel unable to agree to all of the license terms and therefore cannot use the software legally.

Unfortunately, most personnel in computer shops seem to be totally unaware of this possibility. If you ask whether you can buy this or that notebook without the "preinstalled operating system," they look at you and say "Do you want to buy it, or not?" or just "We don't do that." Now, we could discuss whether they are violating the Windows license themselves by not informing you about your rights, but the effort of properly explaining things to a salesman could just be a waste of time.

Rather, you should contact the manufacturer of the notebook and ask them about their standard procedure of returning Windows, so you don't have to bother with your local electronic store. Because I recently did this myself, I can give you a short how-to here, which worked for me.

0. Before buying the notebook, contact the computer manufacturer's support and request information about their operating system return procedure. Usually, the procedure is somewhat time-critical and only works within a very short time frame after the purchase date (in my case, it was seven days counting from the date printed on the invoice).

The following steps are an example for a specific vendor. If the procedure is different for your chosen computer brand, just ignore my remarks here and follow that manufacturer's instructions. ;-)

1. Immediately after receiving the invoice for the newly bought computer, you start a support request, for which you might need a copy of the invoice and the computer's "serial number," which is listed on a sticker somewhere on the computer case. Copy and document (photos!) everything you do, but DO NOT OPEN THE CD OR DVD PACKAGE! If seals are broken, the software counts as "used" and cannot be returned, even if you did nothing with it.

2. By requesting a service number on the manufacturer's homepage, it seems you must declare the unused operating system as a "defect," in order to get the correct forms for the return procedure, because the OS is a "part" that can be replaced or returned.

3. You should get a service number (RMA, "Return Merchandize Authorization") and a form that demands you do the following.

4. If the license sticker came already attached to the computer, carefully (!) remove it from the case. You need to be extra careful, because it is designed to tear apart easily when being detached, so use a spoon or knife and do everything slowly. The undamaged license sticker should then be attached to the appropriate field on the OS return form.

5. Send the original, unopened CD or DVD, together with the return forms filled out with your contact address and account info for receiving the money, to the support address specified by the manufacturer. Make sure the RMA number is also written on the envelope, so the package will be handled quickly by the correct manufacturer's department.

Don't expect to receive the "end user" price for the returned operating system, because the OEM price of Windows for computer manufacturers is, of course, way cheaper than the list prices in shops, but it should still be enough for spending a nice evening at the movies with the kids. ;-)

Sound Card Not Found ... or Was It?

Question:

Hi Klaus: I'm running your Knoppix 6.2 Live DVD, and it's great. I just have a quick question about the output extracted from dmesg and lspci (Listing 2).

Listing 2: dmesg and lspci Output

dmesg output

[    0.653313] Advanced Linux Sound Architecture Driver Version 1.0.20.
[    0.653559] ALSA device list:
[    0.653560]   No soundcards found.

lspci output 00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60)

The question is: Why does it say No soundcards found when lspci shows the AC97 Audio Controller and the sound works just fine? Glen

Answer:

This is related to the way the kernel is configured in Knoppix. Things that are used at a very early point of the autoconfiguration procedure, such as hard disk controllers and input/output devices, are compiled statically into the kernel. This also applies to the basic audio system functions of ALSA, although you made me think about whether this is really necessary ... . Anyway, the dmesg output just says that ALSA has been loaded, but no soundcards were detected at that point. Udev will load the soundcard hardware drivers later, and ALSA will happily add them to its internal device list. So, the message you observed is just caused by the sequence of software initialization and hardware detection and does not mean there is an actual error.

Flash Disk Partitioning

Question:

Dear Mr Knopper: I am so impressed by what you managed to put on the 4GB DVD that came with issue 113 of Linux Magazine that I immediately bought another 16GB USB flash stick to install Knoppix 6.3 on and attached that to the keyring in my pocket.

But, there are a few problems. For some reason, the USB stick was partitioned from track 9 up as type b, and I expected that tracks 0-9 were the "primary partition" that "has to be FAT32" as mentioned in the article. I assume that you meant "first primary partition" because I am well aware that Mr. Gates reserves all best things for himself.

But the real problem is in the "Knoppix on a USB Flash or SD Card" box. I do not get a Knoppix Settings menu at all. Although I found Install Knoppix Flash as an item in Preferences, the system does not show the upper sub-window shown in Figure 2 of the Knoppix Installer.

I managed to partition the USB from track 0 up, but, because you forgot to mention the required size and contents, I made a type b partition of 200MB, then 4GB ext2 for Knoppix, and a swap partition of 1GB, after which I have 10GB left for my data in /home, which is not too much for what I want to keep in my pocket.

I am sure that I have partitioned the USB correctly: 1) FAT, 2) Knoppix, 3) swap, 4) extended, and 5) my /home. But when I tried to run mke2fs on that, the (still Knoppix) system said that it does not exist. I had the same error with partitions >8 last week on a 320GB disk and still wonder about its cause. I succeeded by using GParted 0.5.1, but I wonder what is wrong. Can you please help me out? Nieuwenhuizen

Answer:

The Settings menu really is called Preferences; you found the right menu. There are two different modes of installing Knoppix:

Mode 1: Install on Flash. For this mode, you need a USB flash disk, SD card, or hard disk with just one single primary FAT32 partition as the first and only partition.

The partition type should be c (FAT32 LBA). This is how many USB flash pens are partitioned and formatted by default. During installation, the DVD content is simply copied to the FAT filesystem, which gets a syslinux partition and master boot record. isolinux.cfg is renamed syslinux.cfg, and everything works just like it did on the DVD except for the additional overlay file, which is created at startup and lets you store personal configuration and data.

Mode 2: Install on Hard Disk. In this mode, you need a system partition of about 12GB for system and personal data and a Linux swap partition of at least 1GB. The installer can create the partition table and filesystems on its own. The DVD content is being decompressed, so the resulting system will look just like a normal Debian GNU/Linux installation.

Mode 1 is surely the simplest and is recommended for installation on portable disks or small hard disks because the base system is still compressed and therefore using available diskspace very efficiently.

Mode 2 is useful if you plan to run multiple operating systems from the same disk, if you want to run regular Debian updates, and if limited space is not an issue.

The USB flash disk partitioning you mentioned seems odd to me. For mode 1, the stick should be repartitioned with just a single FAT32 partition, then the flash disk installation should work instantly.