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

Printer Not Starting at Boot

Question:

Hi Klaus: While surfing around, I discovered your articles and wondered if you could help me with your vast knowledge.

I have been working with Ubuntu 9.04 only for a month, and I have problems with my printers. I have a single-boot Linux laptop, and I installed two printers (an OKI c3200 and an Epson dx5000) without any trouble both locally and over a network using Samba for Windows XP.

When I tried to add a third printer, a Brother 5440cn that wasn't in the list, I looked it up on the Internet and started adding commands on a terminal to try and make it work, but with no joy. The surprise came the next day when I switched on my laptop and discovered that all my printers had disappeared. Now I solve this problem every day when I power up by typing sudo cupsd at a terminal. After I do this, my printers show up and work, but it is a pain.

How can I solve this problem? I've looked it up, and some people say I have to mark cups in the initial services; others recommend I use cupsys, but I don't dare do anything else at random. Your help would be much appreciated.Alfonso

Answer:

To me, it looks like you - accidentally - updated the printer server cupsd during your experiments with new drivers, which is not necessarily bad. The problem is that the upgrade did not install the start scripts for automatically starting cups at boot in the right places.

Or, it is possible that a special setting is preventing the cups server from being started at boottime (which should be indicated by some kind of startup message saying, "cupsd has been disabled" during boot - please check). Therefore, although otherwise configured correctly, cups only starts manually on your computer.

To get cups to start again automatically, there are several ways you can go. However, allow me to give a general, well-meant warning: Please don't just start typing commands you find on the Internet if you don't know what they will do.

Although most hints in forums are correct in their individual context, they might not do what you expect in your special case and could lead to misconfigurations or, in the worst case, a completely broken system.

If you are using a Debian derivate, such as Ubuntu, each service has a startscript in the /etc/init.d/ directory, and a so-called runlevel script in one of the /etc/rcN.d/ (where N is between 1 and 5) directories that is called during startup.

For services that have to be called very early during startup and are used in all runlevels, the corresponding scripts are placed in /etc/rcS.d, but this is not required for the printer server cupsd. The command

ls -l /etc/init.d/cups* /etc/rc*.d/*cups*

will show you the location of the original cups startscript and the copies (or rather, symbolic links) in the runlevel directories. In your case, this will probably just show this result:

-rwxr-xr-x 1 root root 2556 21. Mai 19:02 /etc/init.d/cups

Remark: In older systems, the script was called cupsys, which your previous research also showed. To create the runlevel scripts, you have several options:

  1. Copy or symlink /etc/init.d/cups to /etc/rc5.d/S50cups
    ln -s /etc/init.d/cups /etc/rc5.d/S50cups

for runlevel 5, which is the runlevel for the graphical environment.

  1. Use the standard Debian command as root to re-add the service to start on bootup:
    update-rc.d -f cups defaults

If update-rc.d tells you that symlinks already exist (maybe in other runlevels), you can remove them first with

update-rc.d -f cups remove

and then recreate them.

  1. Re-run the cups server's installation script with
    dpkg-reconfigure cups

without actually reinstalling.

  1. Use your favorite graphical administration tool for your distribution, which will accomplish the same thing as either option 1 or 2.

Now the cups server should start automatically at boot again.

Running Live System in a chroot Environment

Question:

I am currently running 64-bit Debian (Sid/Lenny) and would like to have a Knoppix chroot using schroot. How do I use Knoppix as a chroot? (Do I need cloop?) I would be content to use the ISO, an extracted form of the ISO, or preferably the installed version. Thank you for your time. Don Davis

Answer:

A chroot changes the root filesystem for the current process to the given directory, which means that the directory must contain all executables and libraries at the correct place.

For Knoppix, the KNOPPIX/KNOPPIX file on the DVD contains a Debian GNU/Linux installation as a compressed, read-only ISO filesystem. Provided you can mount it somewhere, it is possible to use this as the chroot environment.

If you have the cloop kernel module available, you can mount KNOPPIX/KNOPPIX like this:

  1. Create (as root) the cloop devices in /dev, just in case you don't have them yet:
    mknod /dev/cloop b 240 0
    mknod /dev/cloop1 b 240 1
  1. Load (as root) the module and assign the compressed file to a cloop device:
    insmod cloop file=/media/dvd/KNOPPIX/KNOPPIX

Or, if cloop is already loaded:

losetup /dev/cloop1 /media/dvd/KNOPPIX/KNOPPIX
  1. Mount (as root) the device to a convenient location:
    mkdir /KNOPPIX
    mount -o ro,suid,dev,exec /dev/cloop /KNOPPIX
  1. Make (as root) /sys and /proc and /tmp viewable by your later chroot environment:
    mount --bind /sys /KNOPPIX/sys
    mount --bind /proc /KNOPPIX/proc
    mount --bind /tmp /KNOPPIX/tmp
  1. Do (as root) the chroot:
    chroot /KNOPPIX /bin/bash

If you get /dev/null: Permission denied, your mount command lacked the suid,dev options to access the devices.

If you don't have the cloop kernel module (which you can always get from the Knoppix Live CD sources site [1]), you can alternately uncompress the KNOPPIX/KNOPPIX file to an ISO file:

extract_compressed_fs /media/dvd/KNOPPIX/KNOPPIX - > /tmp/KNOPPIX-FS.iso

Then you can

mount -o loop,ro,suid,dev,exec /tmp/KNOPPIX-FS.iso /KNOPPIX

as in step 3 before.

For write access, you need an overlay like Aufs. Or, you can just mount a ramdisk into those places that are usually writable, which is at least the home directory of the user (or root) and /tmp (the latter was already done in step 4).

If you want to use graphical programs, make sure that $DISPLAY is set correctly to :0. Because the socket in use by xorg has been transported via mount --bind /tmp in step 4, accessing the X server should be possible from within the chroot environment without even using the TCP socket method.

Failed Installation in Virtual Environment

Question:

I am an MCSA sys admin eager to learn more about Linux. I've done some work with Ubuntu Server 8.04, and I'm madly in love with it (then I discovered openSUSE, then Fedora, and the list goes on ...). However, one thing strikes me, and perhaps it's because I'm doing something wrong: I've installed Ubuntu 8.04.2/3 Server 32 and 64 dozens of times for testing and evaluation purposes on PCs and virtual machines, and in more instances than I would have liked, I encountered a problem where the installation would simply freeze at

Configuring APT (some percentage) ...

and the only solution was to reinstall and hope it wouldn't happen again. Thanks very much for your help. Erez

Answer:

To answer this, I would need some feedback about the installation environment. "Configuring APT ..." is, in the Debian GNU/Linux family, the stage where the Automatic Package Tool (Apt) seeks installation media from which software packages can be installed. It should not appear in systems that have RPM as package management, but the symptoms can be similar there, too.

A complete freeze (i.e., the keyboard does nothing and not even the Caps Lock LED is working when you press this key) means that the hardware is no longer functional, which can happen with interrupt problems or BIOS errors during hardware initialization.

Although it seldom occurs, it would indicate a misconfiguration of cables or BIOS settings. If installation got as far as displaying Apt configuring itself to download packages, I assume you got past the initial boot stage and the installer is trying to find a DVD or network drivers to download updates from the official servers of your distribution.

If you get a hardware freeze at this stage, the loading of network drivers might have caused interrupt problems and system failure. Sometimes the keyboard starts blinking when such a problem appears, and the only way to continue is a reset.

More likely, the installation process is waiting for something but receives confusing or unexpected feedback. For example, a network IP and correct gateway might have been acquired through DHCP, but a firewall blocks direct access of FTP or WWW servers without a connection failure ICMP reply. So, the installer assumes a working Internet connection, but because it never receives data or a timeout, it just sits there and waits. One solution might be just disconnecting the (physical or virtual) network or making sure that external servers can be reached. Or, perhaps another DVD-ROM is present in the (virtual) computer's BIOS settings, but with no real device (or file) attached to the cable.

To find errors or have a look on what's happening, you can work at the shell level during installation at a certain point by switching consoles. Most distributions allow this, although the shell consoles are at different keys. Try Ctrl+Alt+F2 through all available Fx keys, until you find a console that has a shell or shows "press return to activate console." In the rescue shell, you have a minimal environment, but it's sufficient for checking errors or doing quick reconfigurations, or even killing non-responding parts of the installation process.

Of course, it is always possible that the installer itself is flawed because of a programming error. Especially for the message you mentioned, I found out about a bug in Ubuntu's installer that caused the Apt configuration to halt at about 80%, but apparently the error has been fixed in newer versions [2].

DOS and Equivalent Linux Commands

Question:

Old-timer here. Is there a list of commands (like DOS dir, etc.) for Ubuntu 9.04 that a person can get? I'm a newbie to Ubuntu, and I'm used to using DOS and Apple ][gs. D.J. Sasse

Answer:

Since I had the chance to learn DOS quite a while ago, I can give you a short comparison of commands here.

Please note that the exact syntax and options for each command is different from what you are used to on DOS and what is standard in Unix systems. The --help option tells you how to call a command correctly, and

man command

shows the online documentation for the given command. A more descriptive list can be found on the Unix for DOS users web page [3]

INFO
[1] Knoppix Live CD sources and updates: http://debian-knoppix.alioth.debian.org/
[2] Launchpad (Bug #445385): https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/445385
[3] Unix for DOS users: http://www.yolinux.com/TUTORIALS/unix_for_dos_users.html