Hack 68 Repair Debian Packages

 < Day Day Up > 

figs/moderate.gif figs/hack68.gif

Knoppix is not only based on Debian; it also comes with a full set of tools to manage and change Debian packages .

Knoppix is over 90% pure Debian packages, and if you install Knoppix to your hard drive, you find that the programs and utilities are installed where they would be on a regular Debian system. It might not then surprise you to know that Knoppix comes with many of Debian's packaging tools and is an excellent rescue disk for fixing Debian-specific problems. This hack describes how to downgrade a broken package that is stopping you from booting, fix a broken dpkg package, and perform a few other Debian-specific fixes.

Knoppix includes the Debian dpkg tools: dpkg , dpkg-buildpackage , dpkg-reconfigure , and dpkg-source . With these tools, you can rescue a Debian system that might not boot because of a broken package or corrupted install.

For instance, if the modutils package (containing useful utilities such as modprobe and insmod ) is corrupted, your system cannot load modules and probably won't boot. To correct this, boot Knoppix and mount the root Debian partition (in this example, /dev/hda1 ) as read/write:

 knoppix@ttyp0[knoppix]$  sudo mount -o rw /dev/hda1 /mnt/hda1  

Check to see if you have a previous version of modutils under /var/cache/apt/archives/ . If not, open up a browser and use the search feature on http://packages.debian.org to locate your package from one of Debian's mirrors. In this case, modutils is located at http://http.us.debian.org/debian/pool/main/m/modutils/. This mirror contains packages for the architectures that Debian supports, so make sure to grab the package corresponding to your architecture (likely, the package ending in "i386.deb").

Once you have obtained the package that corresponds to your architecture, run dpkg in its chroot mode to install the package to the mounted Debian system. In this example, the Debian root directory is mounted at /mnt/hda1 , so the command is:

 knoppix@tty0[knoppix]$  sudo dpkg --root  /mnt/hda1    -i  modutils_version_i386.deb   

Of course, replace the mount point to match where your Debian root partition is mounted, and change the package to whichever package you need to install. Dpkg runs through the full downgrade with any reconfiguration you might need to perform, and once dpkg is finished, you should be able to reboot into the system with a fixed package.

You can also use this method to fix a broken or corrupted dpkg package. Obviously, if your package installation program is broken, you can't use it to fix itself. But you can use Knoppix's working dpkg to install a new package manager in a chroot environment. After you download the appropriate package from http://http.us.debian.org/debian/pool/main/d/dpkg/, run this command:

 knoppix@tty0[knoppix]$  sudo dpkg --root  /mnt/hda1    -i  dpkg_version_i386.deb   

You can also download the replacement package, convert it to a tar file, and then untar it in the mounted root directory. Here are the steps to use tar and alien to install the package. Alien is a handy tool that acts as a translator between .tgz , .rpm , and .deb packages, and can convert a file in one format to any of the others. Use alien to convert the package to a tar file before unpacking:

 knoppix@tty0[knoppix]$  sudo alien --to-tgz dpkg_version_i386.deb  knoppix@tty0[knoppix]$  sudo mv  dpkg_version_i386.tgz /mnt/hda1   knoppix@tty0[knoppix]$  cd  /mnt/hda1   knoppix@tty0[hda1]$  tar xzvf  dpkg_version_i386.tgz   

While there are many other packages you can leverage on Knoppix to fix broken Debian systems, generally it's best to fix the Debian system while you are booted into the system itself. Use Knoppix to repair those packages that prevent you from booting, then boot into Debian and repair the rest from there.

 < Day Day Up > 


Knoppix Hacks. 100 Tips and Tricks
Knoppix Hacks. 100 Tips and Tricks
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net