Penguin

Package-related Notes

Rate-limiting apt-get

If you live in NewZealand, you might be interested in rate-limiting downloads thanks to terrible queuing and rate-limiting on many ADSL services.

apt-get(8) uses its own built-in code for retrieving packages via HTTP or FTP, instead of relying on an external program like wget(1), and doesn't offer any rate-limiting options. There are two main ways to throttle its bandwidth consumption anyway:

  • Set up a WebProxy on your LAN which throttles downloads, and configure APT to use it, either via /etc/apt/apt.conf.d settings or with the http_proxy or ftp_proxy EnvironmentVariables.
  • Install the trickle(1) package, which can rate-limit most UserSpace socket connections.

The second route is much easier, but note that using trickle(1) will also rate-limit any child processes spawned by your command -- if APT restarts any daemons, they will be rate-limited! You should therefor do two separate passes with apt-get(8): a trickle(1)-controlled one to download packages, and a separate one without trickle(1) to install the downloaded packages. You can do this with a command such as

trickle -d $KBPS apt-get --download-only upgrade && apt-get upgrade

You may also use trickle only in the http and ftp file retrieval "plug-ins" of apt. For the http method :

dpkg-divert --local --rename /usr/lib/apt/methods/http
echo '#!/bin/sh' > /usr/lib/apt/methods/http
echo '/usr/bin/trickle -s -d 10 /usr/lib/apt/methods/http.distrib' >> /usr/lib/apt/methods/http
chmod 755 /usr/lib/apt/methods/http

Do the same for the ftp method. The "-d 10" sets a ratelimit of 10KB/s. You may want to take out the -s/-d switches and configure trickled.

dpkg doesn't ask me questions any more?

You have configured debconf not to ask questions, possibly after an AutoInstall. You can fix this using the following command:

dpkg-reconfigure --frontend=dialog --priority=low debconf

Excluding a particular package from automatic upgrades

Put the package on hold, like so:

echo "packagename hold" | dpkg --set-selections

How to get back lost files from your packages

cd /var/lib/dpkg/info/
for PKG in *.list ; do
     while read FILE ; do
         [ -r "$FILE" ] && continue
         echo "${PKG%%.list}"
         break
     done < "$PKG"
done \
| xargs apt-get -y install --reinstall

It will look at your installed packages to see what files should be installed, then reinstall any packages for which files are missing.

Reinstalling all packages on a system

dpkg --get-selections | awk '$2 == "install" { print $1 }' | xargs apt-get -y --reinstall install

Removing all packages marked as 'deinstall'

dpkg --get-selections | grep deinstall | cut -f1 | xargs dpkg --purge

Irritations using dpkg -l 'glob'

The COLUMNS EnvironmentVariable controls the width of dpkg(1)'s output, and thus how much of the package names gets chopped off. Note its behaviour differs depending on whether stdout is a terminal or not. Eg.:

COLUMNS=160 dpkg -l 'lib*' | awk '{print $1,$2}'

Some other people's notes on dealing with DebianLinux

While the following page has some good tips, it seems to have been written by someone who not only thought that they should be able to instantly know every nuance of a piece of software without reading a manual or anything like that, but needed to take a few CTFD pills before writing this page. That said, it's mildly amusing and has a few good points.

http://www.miketaylor.org.uk/tech/wxinmfpl/debian.html

The main cause of this person's problems was mixing packages from stable and testing. One of the best features about DebianLinux is that (in stable, at least) the debian packages work very well with the other packages in the distribution. They've been tested lots, and spent a lot of time having only bug-fixes applied. With Testing or Unstable, it is likely that the developers and users building and using packages are using packages from the same repository. Often packages from testing may not work very well with an older library from stable, but the package doesn't have the required dependency on a newer version, simply because the DebianLinux maintainer doesn't know that the program misbehaves. If someone reports it as a bug, then the package will probably get the required dependency. But if very few people mix-n-match packages from stable and testing, all these little problems won't be discovered and resolved.

Moral: if you use testing or unstable, don't keep old versions of packages around while only upgrading some of them.

Downgrading from unstable to stable

This is not a process to be taken lightly. It will probably be faster, safer and easier to just do a complete reinstall.

Steps:

  1. Backup the system
  2. Uninstall all unnecessary packages (Apache, KDE, GNOME, etc)
  3. Get a copy of a statically linked bash(1) and put it in /bin/ somewhere
  4. Edit /etc/debian_version to the version you want
  5. Edit /etc/apt/sources.list to the version you want
  6. Issue apt-get --reinstall install binutils which will reinstall and pretty much everything

You may find yourself in a situation which you have an old linker that won't let you uninstall a relatively new libc6. The solution to this problem is to reverse the changes in /etc/apt/sources.list, get a new linker, get an old libc6, then get an old linker.

Reconfiguring the bootloader automagically after kernel package install/remove

If you use kernel packages, you can configure the machine to run a postinstall/postremove script. This is normally taken care of during system install time (if you install a machine with GRUB, then update-grub is run after kernel install/remove), but if you change bootloaders, it may not be.

Look in /etc/kernel-img.conf (create it if it doesn't exist), and set the postinst_hook and postrm_hook values accordingly.

postinst_hook=/sbin/update-grub
postrm_hook=/sbin/update-grub

Compiling debs for modules

If you run 'make-kpkg modules_image', make-kpkg(1) will go through /usr/src/modules and build modules .debs for all the subdirectories of Debian-build-able modules you have in there.

Miscellaneous Notes

Setting up two NICs to bridge

Assuming you have the appropriate tools installed (bridge-utils), you just need to add a stanza like the following to /etc/network/interfaces:

auto br0
iface br0 inet static
  address 10.66.100.1
  netmask 255.255.255.0
  gateway 10.66.100.254
  bridge-ports eth0 eth1

Note that you should not have a separate stanza for eth0 and eth1.

How on earth do I create extended partitions when using the Debian installer?

If you create logical partitions then a extended partition will be automatically created to house it. Don't worry! :)

I installed >1gb of ram but it doesn't show up

The default debian 386 kernel package doesn't have bigmem support. Try installing a more specific image, eg 686 (in the 'kernel-image-2.6-686' package).

The installer can't see my $new_device

Kenshi Muto has built a Sarge debian-installer CD based on the 2.6.15 kernel. It might be what you need. Otherwise, install onto an IDE disk and move your installation.

Debian Books

There are several books available to teach you about Debian.

Other pages

In addition to this page, you should also take a look at


CategoryDebian