I just ran (not on purpose!) rm -rf /bin
.
I've booted down the computer and am using Finnix to try to recover from it. I have succeeded in mounting the drive, and confirmed that, yes, the entire /bin
folder is deleted.
Is it possible to recover from this without reinstalling the OS?
I'm thinking that I could setup a VM with the same OS and architecture (Ubuntu Server 11.10 alpha release, x86) and install all the packages I had installed on the server, then just copy the /bin
folder.
Will this work? Am I better off just starting over?
In general, I'd lean towards a reinstall (from the backups you are absolutely supposed to have). But I'm feeling hackish, so here's another way (assuming that your system is mounted under
/target
):Get a list of all the installed packages that have files in
/bin
:(On my Debian Squeeze system that's a total of 34 packages, pretty much all of which are core)
Download each of those packages (I couldn't be bothered to script this bit, so just hit up packages.ubuntu.com and download them into somewhere under
/target
). If you're lucky some of the packages might still be floating around in/target/var/cache/apt/archives
.For each package, run
/target/usr/bin/dpkg -x <package> /target
. I'm fairly certaindpkg
is all self-contained these days, and shouldn't call out to anything in/bin
itself.Once you've got the system back on it's feet, you should make sure and run an
apt-get --reinstall install <all the packages from step 1>
, because (since you're running a pre-release, which Sysadmin Cat says is a no-no on production systems) the versions of the packages you just extracted are likely to be different from those that were on the system before, and you'll want to make sure the system knows exactly what's what.While your strategy may work (there are good chances for it, more if once you copy back the bin directory, you do an apt-get reinstall of all the packages in you system), it can yield problems in the future because you may get an unstable server.
If that would have happened to me, I would reinstall and restore from the daily backup. You have a daily backup - a disaster recovery plan - don't you?
In case you didn't have a disaster recovery plan, I would suggest to backup all the config files and the data you want to preserve and go ahead with a reinstall. That way you'll be sure that you'll end with a stable server again.
I would try creating a VM then copying the contents of
/bin
to your damaged machine. That should get you up and running. Then runwhich should reinstall all the packages that were on your system.
The easiest way, if you have access to the machine, is to mount the filesystem, take a backup of all your data (just as a precaution).
Then you can re-install ubuntu like a normal install; in principle all your data (home dir, etc and var) should still be there.
There is a way to reinstall all packages so that /bin is repopulated, but that's fairly complicated.
The files are gone. While you can attempt to "undelete" files - I wouldn't recommend it.
Note: I do not run Ubuntu (and haven't used Debian distros for a while). However I have done various distros recoveries in the past all following similar scenario.
Your best course of action:
/mnt/mint
)/mnt/mint
- not sure/bin
contents of liveCD over to/mnt/mint/bin
but I do not know whether liveCD for mint uses busybox which may complicate matters - alternative #1 in that case seems safer.generally this should return your files by "brute-reinstall" of everything you have. You can do bit more "clever" tricks and query for all packages that dropped binaries in /bin