Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reinstalling debian /bin

On Sun, Sep 17, 2006 at 01:53:35PM -0400, James Kramer wrote:
> While working on Xen setup I managed to delete /bin  by using the command
> rm -R /bin. I don't think that I can recover the /bin files but I
> should be able to reinstall the packages. I have a backup of all my
> data files and most config files that were in /etc.  I can boot into a
> different debian OS using grub so I can access the partition and
> files.  I can chroot the particular partition.  Can someone suggest
> how to reinstall the system.  If I do a complete debian reinstalll
> from CD on top the partition would it retain my old directories and
> files.  I tried to chroot the root partion figuring that I could use
> apt-get to reinstall the packages but I can not figure out the proper
> way to do it. 

You are going to encounter a chicken-and-egg scenario that is not
going to be easy to back out of. The problem is many, many packages
depend/predepend on programs in /bin. It is probably that an apt-get
--reinstall will fail due to the missing files.

"dpkg -S /bin" will list most packages that have files in /bin. (If
the root directory in question is under /mnt, use "dpkg --root=/mnt -S
/bin".) The files that are missed would be files created by package
maintainer scripts instead of being unpacked through dpkg. This is
almost a non-issue for /bin, but would be an issue for most other

Gather up the corresponding debs. For each deb, run dpkg -x (deb)
(tmpdir). Copy over the files in (tmpdir)/bin into the target's
/bin. Check the target's /bin/sh; make it a symlink to bash if it
isn't already.

You now have a Debian system that is 95% of the way to being
whole. Boot into it and run apt-get --reinstall install (packages in

As hinted above, there may be packages that do not unpack any files
into /bin (and thus won't appear in dpkg -S /bin), but have maintainer
scripts that create files in /bin behind dpkg's back. If you are
truely concerned about that, then apt-get --reinstall install all the
packages on the system. Be warned that this can cause other problems:
It calls the maintainer scripts for every package, and some of them
are not idempotent.

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /