TODO forever when life runs faster than you can afford

21Aug/100

How comes my modem gets switched when plugged during boot?

This post is inspired by a similar question made by a Linux user. Exact question answered by this post is:

When my USB modem is plugged during boot, it gets switched, although modem-modeswitch, Usb-ModeSwitch and Sakis3G are not installed on my system. How is that possible?

Some modems automatically switch mode (and, most of them, their product ID along the way), on their own (without the need for Usb-ModeSwitch), when they are simply "ejected". Reason we call it "eject" is that they indeed actually "fool" computer/operating system into presenting themselves as USB CD-ROMs (their commercial name now turns relative: "ZeroCD"). When those pseudo-CD-ROM devices receive the "eject-your-media" SCSI command, they instead switch mode, and become usable as modems.

Some others, switch mode (again, on their own), if being plugged on computer for some seconds (e.g. modem might switch on its own after 60 seconds of inactivity have expired). This one case is self-explained and we will not bother more on this post.

You may have already encounter guides, for using such modems, which simply instruct you to request an "Eject" from your File Manager, once that CD-ROM device appears: you select "Eject", CD-ROM disappears and a modem comes back on its place.

If you are using a Linux kernel version around 2.6.24-2.6.28, you may be surprised that your newly attached "CD-ROM" never made it to appear on your File Manager. So, you cannot eject it, and therefore, cannot use it. Reason is that those kernel versions employed a (later removed) workaround for preventing usb_storage module from attaching to those devices. If you are running such a kernel version, you might have to edit /drivers/usb/storage/unusual_devs.h, remove your modem's USB IDs from being listed, and recompile. Or, simply install Usb-ModeSwitch (recommended).

Going back to our "investigation", we still seek what actually happens, and your modem is switched already, when plugged during boot. Answer is that someone else "ejects" it, before Linux kernel is even loaded. Guess who is it?

Your computer's BIOS!

Some BIOSes (either erratically, or upon your directions), before passing boot sequence on your hard disk's MBR (Master Boot Record), where your boot loader resides (GRUB, Lilo etc.), they first check whether a bootable media is inserted on any attached CD-ROM/DVD-ROM. Given the fact that your modem pretends being one:

  1. BIOS has a look at it,
  2. Discovers it is not bootable, and
  3. Reverts procedure (so that operating system to be loaded, finds CD-ROM device on expected state).

During revert/reset procedure, it instructs your "CD-ROM" accordingly (i.e. to consider itself "not-mounted" and allow itself to go in power save mode, and allow having its tray opened etc.). This is where your modem's firmware considers it was instructed to be "ejected" (actually, it was not. BIOS didn't tell it to eject. If it had, your system would be ejecting discs out of its real CD-ROM as well, during boot, but it doesn't. Does it?).

When Linux kernel is given control (BIOS->MODEM->BIOS->MBR->Loader->Kernel), modem has already switched (or is about to appear switched, while system still boots). This leads to another one "bad" effect: some (badly implemented) udev rules (of the "hotplug" subsystem) never get triggered. Reason is that device was never "hotplugged", it had been there during boot. These all lead into some processes (which rely on badly implemented udev rules, for being informed accordingly) ignoring the presence of your device and may even prevent you from actually using it.

If you need to disable this behavior, you need to investigate whether it is possible to alter your BIOS's boot sequence (some laptop BIOSes may keep interfering, even if instructed not to boot from CD-ROMs). Either instruct it to directly boot from your hard disk, or have it consider optical drives not a valid boot source.

This behavior, although frustrating, could actually be really useful. This means you can actually:

  1. reboot your Linux system (arghh!), with modem being plugged,
  2. (may need to manually load "option" module to) be able to use your 3G modem (until unplugged again), in order to
  3. download and install Usb-ModeSwitch and/or Sakis3G, so that
  4. your system can now utilize modem even if it is hot-plugged.
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.