Klaus Knopper answers your Linux questions

Ask Klaus!


Klaus Knopper is the creator of Knoppix and co-founder of 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

Android Hotspot

Question:

Dear Klaus, I have an Android mobile phone (Samsung Galaxy i7500), and I want to use it for the broadband mobile network connection on my laptop with Ubuntu Linux 10.04. I followed the instructions on a web page, "How to tether your Android to Ubuntu without rooting" [1]. I also checked the advice at Linux Magazine online (from Dmitri Popov [2]). I've done everything that was recommended there, but it does not work!?!

I cannot establish a connection with my Android. Something is obviously missing, but I do not know what. I am not a beginner with Linux; I am also quite sure I did not make any mistake in the procedure. Maybe it is something people on the forums just forgot to include, and it is an incomplete story. I will appreciate your help! Best regards, Zoran Medved

Answer:

The article at the AndroidandMe Forums [1] looks like a good description of what to do on the Linux side; however, there are a few catches you might have run into. Unfortunately, it's hard to guess without a more precise description of the connection failure. But I'll try.

The method you chose is the one without modification of your Android phone's firmware, which means, of course, more modifications on the Linux side.

The only modification for your Android phone is the app proxoid [3], which you can download. The proxoid installation page [4] describes what exactly to do on the phone and what to do on Linux.

To see whether the Android/proxoid part worked, you should check for the proxoid item and make sure that the proxoid app can access the Internet. You also need to switch on USB communication on the phone and USB debugging in your phone's configuration, which is located in Android's Development settings, as described on the proxoid installation web page.

Now for the Linux part. When plugged in via USB, you should see something in udev's monitor, which can be started by

udevadm monitor
(Control-C to stop monitoring udev)

from the shell. If nothing happens when you plug in the phone, either the USB cable is not working or USB is switched off on the phone.

The proxoid installation for Linux page [5] describes how to modify the udev hardware detection service to recognize the phone and set permissions accordingly so that you can access the device without administrator rights. You will have to be root to create the udev modifications, but just once. In theory, restarting udev with

/etc/init.d/udev restart

should not be necessary, but with a recent enough udev, it does not hurt either.

After the modification, removing and plugging in the phone again should create a new USB device file in /dev, which can be named /dev/ttyUSB* or /dev/ttyACM*, or even a totally different name. The command

ls -lrtd /dev/* | tail -20

will show you the 20 most recently added device files.

At this point, the hardware-dependent stuff is finished.

Now you need to get the Android development kit, which runs not on Android but on your Linux system. Contrary to the installation instructions, you need the TAR archive, not the ZIP file: android-sdk*.tar.gz.

Of all the files included in the SDK, you only need a few. To begin, change to the extracted directory and check for adb. The command that runs the proxy on your Linux box, which will then connect to the phone and initiate a proxy server on the local port, 8080, is as follows:

./adb forward tcp:8080 tcp:8080

Please note that you have to issue this command every time you want to use your phone as proxy to the Internet, as opposed to the hardware stuff that you only need to configure once.

You might get a message saying that something else is already running on localhost port 8080 - maybe an erroneously started squid proxy. In this case, you will have to choose a different local port for your proxy.

You can check whether a local connection works by connecting to the local port 8080 on your computer with telnet or nc:

nc localhost 8080
(if it sits there and waits for input,
 the connection works)
<Ctrl-C>

If you did not get a "connection refused" message, then your proxy is up and running. Now the only part left is setting the proxy for your web browser to server localhost and port 8080 (or a different port if 8080 is already taken). This can be done for a running shell with

export http_proxy=http://localhost:8080

which affects only web browsers started from this shell after the command or after setting the proxy in Firefox preferences under Tools | Options | Advanced | Network | Settings.

USB Install from Scratch

Question:

Hello, Klaus, I have been reading your Ask Klaus Q&A. Inspired by a Knoppix USB installation, I took a challenge to install Ubuntu manually on a USB, but I met a couple of problems. After trying to solve them, I still could not find the solution. I decided to post them to the Ubuntu Forum site, hoping to get help from more experienced users, but none came.

From a Dell D420 laptop, I "installed" the Ubuntu 9.10 (Karmic Koala) kernel 2.6.31-14-generic from a Live CD onto a USB drive by copying the content and booting from GRUB.

The USB is divided in two partitions:

To do this, I:

Then, I formatted the newly created partition for Windows,

sudo mkfs.vfat -F 32 -c /dev/sdc1
sudo dosfslabel /dev/sdc1 UBUNTULIVE

mounted the Windows partition,

sudo mkdir -p /media/USBDRIVE
sudo mount /dev/sdc1 /media/USBDRIVE

installed GRUB on the Windows partition of the USB drive,

sudo grub-install --no-floppy --root-directory=/media/USBDRIVE /dev/sdc

got the ISO from the CD,

sudo dd if=/dev/cdrom of=/path/to/iso/image.iso
sudo mkdir -p /mnt/isoimage
sudo mount -o loop /path/to/iso/image.iso /mnt/isoimage

copied the kernel and initial ramdisk from the ISO image to the GRUB directory,

sudo cp /mnt/isoimage/casper/{vmlinuz,initrd.gz} /media/USBDRIVE/boot/
sudo umount /mnt/isoimage
sudo rmdir /mnt/isoimage

created a persistent filesystem to store data and customizations,

dd if=/dev/zero of=/media/USBDRIVE/casper-rw bs=1M count=256
mkfs.ext3 -F /media/USBDRIVE/casper-rw

wrote the ISO image to the hidden partition,

sudo dd if=/path/to/iso/image.iso of=/dev/sdc2

created a nice GRUB boot menu,

sudo nano /media/USBDRIVE/boot/grub/grub.conf
default 0
timeout 10
title Ubuntu (Live)
root (hd0,0)
kernel /boot/vmlinuz
initrd /boot/initrd.gz

unmounted the Windows partition of the USB drive,

sudo umount /media/USBDRIVE
sudo rmdir /media/USBDRIVE

and synced up and unplugged:

sync

When I boot Ubuntu from the USB drive, at best, I get dropped to the initramfs prompt. At worst, I do not get anywhere; instead, I am thrown to an sh:grub> prompt, along with the following text:

GNU GRUB version 1.97~beta4
[ Minimal BASH-like line editing is supported. For ... device/file completions. ]
sh:grub>

I have tried to edit /boot/grub/menu.lst. Also, at the GRUB prompt, I did try several options:

sh:grub>insmod /boot/grub/linux.mod
sh:grub>set root=(hd0,1)
sh:grub>linux /boot/vmlinuz root=/dev/sda1
sh:grub>initrd /boot/initrd
sh:grub>boot

I also tried root=UUID=xxxx, but nothing worked. Moreover, when I tried the following

sh:grub>loopback loop0 /ubuntu/disks/root.disk

the system complained, saying /ubuntu/disks/ does not exist.

Among the errors I get are:

mount: mounting /dev/sda1 on /root failed: no such device
mount: mounting /sys on /root/sys failed: no such file or directory
mount: mounting /proc on /root/proc failed: no such file or directory

Depending on the kernel options I used at the GRUB prompt (e.g., sh:grub>linux /boot/vmlinuz root=/dev/sda1), I have had a variation on this error:

mount: mounting /dev/sda1 on /root failed: no such device

I need help or advice, but I want to do everything manually. I know I can use a "Startup Disk Creator" and other tools, but this is all about learning, and so far I have learned a lot. However, now I need some advice on how to resolve this problem. I will very much appreciate your help. Gibson.

Answer:

You did almost everything completely right. The problem with "mounting root filesystem" failures occurs only later, when the kernel boots up and tries to access the hard disk.

The most likely reasons for these problems are:

  1. Is the driver for USB hard disks (uhci-hcd and ehci-hcd and/or ohci-hcd for USB controllers and usb-storage for USB disks) present as a kernel module in the initial ramdisk? If not, you need to create an initrd that contains these essential drivers.
    Don't be confused by the fact that GRUB or isolinux can read the USB device without drivers for loading the kernel; this occurs because they use BIOS routines in the system's "real mode" that are not available to operating systems that operate in "protected mode."
    Linux needs these drivers to access the USB hard disk. Knoppix solves this issue by including all USB controller and storage drivers in the static part of the kernel; for Ubuntu, you need to include them in the initial ramdisk that's loaded together with the kernel.
  1. The kernel tries to mount the root filesystem while detection of USB devices is still in progress and gives up immediately. The easy way to fix this is by adding the kernel option waitroot in GRUB's kernel command line or in the syslinux APPEND line after the kernel image. waitroot will indefinitely wait until the prospective root device (root=/dev/sda2 or root=/dev/sdb2 ?) becomes available.
  1. The operating system you try to boot has its own idea of which partition is the root partition. There is an entry for the root filesystem "/" in /etc/fstab that you might need to change inside the operating system's system partition. In some distros, you can use the UUID or disk label of the filesystem partition; others only support device names.

The lines with GRUB errors are just caused by GRUB's not knowing about the partition device in one of your tested configurations; thus, directory /ubuntu/disks could not be found. It's sometimes tricky to find the correct device scheme for GRUB (i.e., whether (hd0,1) or (hd1,1), or (hd0,2) or (hd1,3) are correct for the root= option). You might have to try several options from the interactive GRUB boot interface and enter the correct findings in GRUB's config file afterward.

USB Printer Failure

Question:

Klaus: I have been anxious to try, once again, a Linux distro. After trying three or four, I'm having a great amount of difficulty with (any) distro recognizing my printer as being USB connected. Serial or parallel, but no USB. Can you offer any suggestions? Thank you, Robert Grau

Answer:

Nowadays, USB printers are the least problematic ones. That is, of course, for Linux-friendly manufacturers who have their printer specifications included in the Common Unix Printing System (CUPS), which virtually every Linux distribution uses.

Look for your printer on the CUPS database [6] to see whether it is supported by CUPS. If so, CUPS should find your printer automatically when plugged in and display it as "new printer," so you can install it with a few clicks. I usually prefer the built-in web configuration tool of CUPS for this, which runs in its own web server at http://localhost:631/ on your computer.

If your printer is not automatically found, or at least listed in the web configuration tool, it might be still possible to add it using a vendor-supplied ppd file that comes with some printers or can be downloaded from the vendor's website. The CUPS configuration page allows you to give the path to the installed ppd file to use it as a kind of "printer driver" (although it mainly contains descriptions for the generic drivers).

Some printers, especially printer/fax/scanner combinations (like the HP multifunction printer series), require additional services. For these, install the hplip package.

If nothing else works, you can try to configure the printer with a driver for an older printer model from the same vendor. Sometimes, vendors rebuild printers by using the same internal chipsets, so the printer just looks different and has a higher version number but still uses the same protocol.

If you still have no luck, I would return the printer as a warranty case. If it does not work in spite of all your efforts, it must be defective (either by design, or broken). You would not accept a non-working printer under Windows, why should you do so under Linux? ;-)

Upgrade Cures Boot Hiccup

Question:

Klaus, Thank you for printing my letter! I was stoked to see it in print! ("Laptop Hangs Fire," Issue 114, May 2010.) I want to follow up your answer with some results.

Before I saw the letter in print, I had figured out that if I disabled my NIC card in the BIOS of my laptop, the problem (laptop getting stuck during boot) went away. Because I almost exclusively use WiFi, that workaround was fine for me. (It is only an annoyance when I backup my laptop because of limited bandwidth and lots of data.) :-)

Unfortunately, just days before I read your answer, I upgraded from Ubuntu 9.10 to 10.04. So, after reading your response, I re-enabled my NIC and attempted to duplicate the problem. Unfortunately, the problem did not return, so I have a feeling you were right to suspect a problem with the network configuration and that the distro upgrade to 10.04 fixed the offending configuration. I am disappointed, however, that I'm unable to report back the exact suggestion that corrected the problem.

Thank you for taking the time to answer my letter in print. I really appreciate your time and advice. The best part is, you were able to put me on the right path when many others in the online forums were not able to do so. Please keep up the good work! You ROCK!! Dave Lamb

Answer:

Thanks for letting me know another solution. :-) Usually, I try to find the cause of the problem to fix it. I know that sometimes just doing an upgrade of the system software, without even problem-specific patches, fixes problems "automagically" because distro and software package maintainers eagerly include improvements and bug fixes in every release.

In this case, I believe it was bad interrupt handling (i.e., your internal NIC being active stole an interrupt from the available pool), so another hardware component necessary for booting got none (or at least, the wrong one).

The upgrade might have caused a new kernel to be installed, which led to different interrupt handling (maybe more shared ACPI-configured interrupts available?), which made everything work again without disabling the NIC. A look at /proc/interrupts might show you the network card(s) and other hardware and their (possibly shared) interrupts. If you get a chance to boot the old system from a backup, you could compare how the interrupt distribution looks there and see what happened (and got fixed) by the upgrade. Also, a faulty local APIC could freeze the system during boot. Boot options that frequently work in "boot freeze" cases are:

linux acpi=off nosmp noapic nolapic

The nolapic option especially seems to cure inexplicable freezes right after loading the kernel for some brand new notebooks. Switching off the local APIC controller usually does not hurt performance or stability; however, some notebooks do require the LAPIC, so it won't always work just to enter this boot option into the boot configuration if you don't need it.

INFO
[1] AndroidandMe Forums: http://forums.androidandme.com/topic/how-to-tether-your-android-to-ubuntu-without-rooting
[2] Productivity Sauce: http://www.linuxpromagazine.com/Online/Blogs/Productivity-Sauce-Dmitri-s-open-source-blend-of-productive-computing/Tether-an-Android-Phone-Using-Proxoid
[3] Proxoid: http://code.google.com/p/proxoid/
[4] Proxoid installation: http://code.google.com/p/proxoid/wiki/installation
[5] Proxoid installation on Linux: http://code.google.com/p/proxoid/wiki/installationLinux
[6] CUPS: http://www.openprinting.org/