Ubuntu: dpkg fails with “failed in buffer_read(fd)”

Recently, I was trying to update (and upgrade) Ubuntu Lucid, and received this error while running apt-get:

dpkg: unrecoverable fatal error, aborting:
failed in buffer_read(fd): files list for package `apparmor': Input/output error
E: Sub-process /usr/bin/dpkg returned an error code (2)

The solution was summarized nicely by Vivek Kapoor; he attributes the solution to C.M. Connelly (from 5 May, 2003). One of the nice things about Connelly’s entry is that he shows you how he debugged the problem he had, and how he fixed it; go read the post.

The error message is coming from dpkg, and refers to the “files list for package `apparmor'“. The files list is in /var/lib/dpkg/info; in this case, /var/lib/dpkg/info/apparmor.list. The problem being referred to in the error message is that, for some reason, this file cannot be read.

This file can be recreated if you have the package on hand; if not, you can fetch it with apt-get install -d package (possibly with the --reinstall option if necessary). The package will be downloaded to /var/cache/apt/archives, and even if a reinstall is attempted, the reinstall will fail (through dpkg) even though the download through apt succeeds.

The info file contains lines like this (using the top five lines of apparmor as an example):

drwxr-xr-x root/root         0 2010-03-30 14:59 ./
drwxr-xr-x root/root         0 2010-03-30 14:59 ./sbin/
-rwxr-xr-x root/root    783108 2010-03-30 14:59 ./sbin/apparmor_parser
drwxr-xr-x root/root         0 2010-03-30 14:59 ./etc/
drwxr-xr-x root/root         0 2010-03-30 14:59 ./etc/apparmor/

To recreate the file, pipe the output from dpkg -c debfile – like this:

dgd@cor:/var/cache/apt/archives$ dpkg -c apparmor_2.5-0ubuntu3_i386.deb |sudo tee /var/lib/dpkg/info/apparmor.list >/dev/null

After that, you should be good to go. You might want to check the disk (using fdisk) and perhaps reinstall the package to make sure all files are okay.

I don’t understand how this dpkg problem can last for seven years now; dpkg should be able to cleanly handle the recreation of this file if necessary, and shouldn’t be reporting obscure messages about its internal workings. From a user perspective – and a system administrator perspective – dpkg should automatically recreate the list file if there are problems with it, or even recreate all control files used by the package.

One very interesting tip was hidden in Connelly’s blog post from 2003: you can use less on a Debian package and it will report useful information (here’s an example from first lines of apparmor):

 new debian package, version 2.0.
 size 350314 bytes: control archive= 3944 bytes.
    2338 bytes,    61 lines      conffiles            
     360 bytes,    18 lines   *  config               #!/bin/sh
     662 bytes,    15 lines      control              
     708 bytes,    10 lines      md5sums              
    3577 bytes,   119 lines   *  postinst             #!/bin/sh
    2402 bytes,    90 lines   *  postrm               #!/bin/sh
    1186 bytes,    52 lines   *  preinst              #!/bin/sh
     959 bytes,    32 lines   *  prerm                #!/bin/sh
     421 bytes,     9 lines      templates            
 Package: apparmor
 Version: 2.5-0ubuntu3
 Architecture: i386
 Maintainer: Ubuntu Core Developers 
 Installed-Size: 2248
 Depends: libc6 (>= 2.8), debconf (>= 0.5) | debconf-2.0, lsb-base, initramfs-tools, debconf
 Suggests: apparmor-profiles, apparmor-docs
 Conflicts: libapache2-mod-apparmor (<< 2.5-0ubuntu2)
 Replaces: apparmor-parser, libapache2-mod-apparmor (<< 2.5-0ubuntu2)
 Section: admin
 Priority: extra
 Homepage: http://apparmor.wiki.kernel.org/
 Description: User-space parser utility for AppArmor
  AppArmor Parser is a user level programs that is used to load in program
  profiles to the AppArmor Security kernel module.

*** Contents:
drwxr-xr-x root/root         0 2010-03-30 14:59 ./
drwxr-xr-x root/root         0 2010-03-30 14:59 ./sbin/

Running Kubuntu on the Compaq nc4010

I’ve not been a big fan of Ubuntu in the past – and perhaps mainly from the aesthetics of it, as well as its reliance on Gnome – but I’ve neer felt I gave it a good test. Favoring KDE as I do, I loaded Kubuntu and gave it a run. I’m already a big fan of APT (through having used APT-RPM all these years) – and Kubuntu didn’t disappoint.

As I mentioned before, Kubuntu recognized everything on the system – bluetooth, PCMCIA, USB, wireless, ethernet, sound, video – it all worked.

Now after several weeks, how does it stack up?

I still don’t like the dpkg way of things: RPM is designed (and properly so, I say) to run unattended. If you use rpm to install, you don’t have to respond to any sort of install choices (there is no “partial install” – either it worked or it didn’t). APT is wonderful: dpkg is not – but that’s just my opinion.

I was surprised to see that, in Kubuntu at least, Synaptic seems to have given way to something called Adept. Not sure which I like better. I do know that I just despise the “dynamic search” that searches while you type. It slows everything down. I also don’t like the fact that I can’t sort things by groups – for instance, I’m always installing shells and languages of all sorts. Can’t I just look at those groups specifically?

I also found that with this hardware, the bluetooth adapter is always disabled (or seems to be) after hibernation. Using the key to re-enable it doesn’t help; the key is either intercepted or ignored by Linux. It’s not hard to make sure it is active after hibernation. First, make sure that the bluetooth is on at startup; if not, press the bluetooth button at the top. During the initial boot, the BIOS is in charge and it knows how to react to a press of this key – and the bluetooth light (blue) will come on.

If the bluetooth is not active after Kubuntu comes up entirely, it may be necessary to restart the bluetooth services:

/etc/init.d/bluetooth stop
/etc/init.d/bluetooth start

Don’t use bluetooth restart; it may be that more time is needed or something else. It may or may not be necessary to restart kbluetooth; if so, stop it from the task bar and run it from the System menu under the K menu.

With kbluetooth, you can tell if bluetooth is active or not: if the entire icon is gray (including the symbol) then there is no bluetooth adapter recognized. If the symbol is white, then there is an adapter present (though it may not be active).

There is also the Synaptics touchpad – but this is good stuff. The touchpad has capabilities that are not well-explained out there:

  • Using a two-finger tap or a three-finger tap results in a right-button click and a middle-button click respectively (at least that’s what it looks like).
  • Dragging your finger from top to bottom (or vice versa) on the extreme right side results in scrolling (similar to a mouse-wheel).
  • Dragging your finger from left to right at the top may result in scrolling left-to-right (I couldn’t test this out).
  • A double-tap and swipe is the equivalent of dragging an object – or at least, it is the equivalent of holding down the mouse button.

I found that both ksynaptics and touchfreeze (for configuring the Synaptics capabilities) are missing from repositories; only gsynaptics is present. There is good documentation from Ubuntu on how to set up a Synaptics driver; I recommend it.

The system as a whole does get hot – and, for whatever silly reason, has exhaust vents on the bottom (a silly idea in my opinion). No wonder people’s laps got hot. I have three film canisters that I set in a triangle to support the machine; it works beautifully. I plan to fill them with sand to keep them from moving around.

This combination of software and hardware is wonderful – the machine is nice, and the system is nice. Everything was integrated with a click: DVD playback, MP3 support, Flash support – it all came down with just a click. Everything is supported. I love this machine.

UNIX Fragmentation

Did you ever notice that while UNIX and Linux versions are uniform in most areas, there are certain areas where every system seems to do things their own way? These are the things that nobody seems satisfied with, and so has to create their own version – and thus confuse new users. From what I’ve seen these areas are:

  • Menu-based system administration tools
  • Package management
  • Locations of user-added software
  • Filesystems

The last two are not so bad – user-added software locations are generally limited to /usr/local and to /opt (if any), and filesystems don’t tend to “wander” from one UNIX to another – and managing filesystems is not done often enough to make the slight differences annoying.

The real annoyances to system administrators tends to be the first two – system administration tools and packaging. Consider these options of system administration tools for various systems:

  • smit (AIX)
  • sam (HP-UX 11v2-)
  • smh (HP-UX 11v3+)
  • yast (SUSE Linux)
  • redhat-config-* (Red Hat)
  • sysadm (Unixware)
  • webmin (portable)

This doesn’t take into account all the others – IRIX, other Linuxes, ad nauseum. What is it about system administration that every last distributor has to do it their own way? Perhaps webmin will help some, but do we really want a web server on every server? Even so, this is becoming a requirement imposed by the distributors already – so might as well standardize on webmin, right? Perhaps not….

And packaging is even worse. We have these options:

  • RPM (Red Hat)
  • pkg (Solaris)
  • depot (HP-UX)
  • dpkg (Debian)
  • pkg (Unixware)
  • Ports Tree (FreeBSD)
  • emerge (Gentoo)
  • pbi (PCBSD)
  • lrp (Linux Router Project and spinoffs)
  • packages (MacOS X)
  • ports (NetBSD)
  • ESP (portable)

What is it that people just can’t leave well enough alone? Perhaps if BSD had come out of Berkeley with these tools, things might have been different.

There is one ray of hope in this ghastly array of choices: the most flexible and powerful (in my opinion) is also portable: RPM. So all of the systems previously mentioned will also run RPM. Too bad that they won’t necessarily run APT-RPM, but that’s another problem.