
254
|
Chapter 9, Administration and Automation
#84 Recover from Debian Disaster
HACK
HACK
#84
Recover from Debian Disaster Hack #84
Restore your Debian system from even the most seemingly unrecoverable
disaster.
We all make mistakes, but the worst accident on a Debian system (or any
Debian-based system, such as Knoppix) is one that causes you to lose the
contents of your /var/lib/dpkg directory. Once that directory is gone, you can
no longer update or install software. These things happen even to the best of
us, so here’s a procedure to get your Debian system back where it was (or
close), without losing any of your data or having to reinstall all of Debian
from scratch.
OK, so you lost the /var/lib/dpkg directory. Heck, if you had /var on its own
partition, you might have lost everything under the /var directory. If that’s
the case, you’ll have a lot more work to do than restoring your Debian pack-
age database. Unfortunately, because every system differs, it’s up to you to
figure out what you need to restore directories other than those required by
Debian. At minimum, you’ll need to create the following directories to start
your recovery process. Log in as root, and run these commands:
# mkdir –p /var/cache/apt/archives
# mkdir –p /var/cache/debconf
# mkdir –p /var/log
# mkdir –p /var/lib/dpkg/info
# mkdir –p /var/lib/dpkg/parts
# mkdir –p /var/lib/dpkg/alternatives
# mkdir –p /var/lib/dpkg/methods
# mkdir ...