Some background:

I accidentally left two problematic repositories in my /etc/apt/sources.list - to be specific, the squeeze-updates repository (changed from "volatile"), and the sid repository. I was testing some things a while ago and needed those repos for some packages not available in the current one. However, I forgot about it and upgraded (apt-get dist-upgrade) with those repositories, and haven't experienced problems until now, prompting me to downgrade.

First, I removed the conflicting sources. Then I followed online instructions to apt pin the stable repositories to force a downgrade. After it completed, hundreds of obsolete packages remained. Being audacious, I crafted (and ran) the following command to attempt to remove them:

while :; do aptitude -y --without-recommends -f remove ?obsolete; if [ ! "$?" = "0" ];then break; fi; done

It did remove the obsolete packages, especially upstream things like the Linux 3.x kernel. However, I saw some other things that got removed, like the software that I installed before the repo change. I should have stopped everything then, but I thought I'd keep going and let it run, knowing that I can recover later. Coming back to the session window later, it had a dialog prompting me whether I want to keep or remove... my currently running kernel.

I really don't want to do a CD reinstall - I have no place to store the 20+ GBs of data (this is a VPS, and I have a very slow internet connection), and reconfiguring everything will take a LOT of time, and I need the server to be running again ASAP.

Supposedly (this is from the Debian mailing list archive), Debian users prefer to do reinstalls via APT, since this is theoretically possible. I have my own reasons to do it via APT.


Is there, at all, in any way possible, to install Debian without resorting to a CD, via APT or other means? I still have access to the Internet on my server.

I'm aiming to do reinstall the base system AND any categories that I've selected during the original installation (CLI) of Debian Squeeze.

  • A biut late, but wasn't you data in a separate partition mounted at /usr/local/ ? If it was you could just reinstall the whole OS as long as you did not reformat that partition.
    – Hennes
    Sep 11, 2013 at 12:55

1 Answer 1


From any working Linux system, you can use Debootstrap or cdebootstrap to perform the initial layout for a Debian installation in a new location. If you have a spare partition, this should be pretty straightforward: format, mount, debootstrap, chroot, configure, add to bootloader, reboot.

  • I think I can still boot the system, but I'm missing some packages. Are there any alias in apt that would let me reinstall the categories, i.e. webserver or fileserver? It hasn't gotten that bad yet. ;) I think using (c)debootstrap would wipe out my current package installation list, so I'm refraining from using it. (That is, if I were to copy the package database from the new system, it would erase the old one.) As always, feel free to correct me - I haven't mucked with the Debian packaging system for a long time, other than apt-get install bla :)
    – Albert H
    Mar 26, 2012 at 15:22
  • 1
    Copying the package database is easy: save dpkg --get-selections, and pipe it into dpkg --set-selections. That being said, if you just need to ensure certain tasks are installed, just use tasksel. You probably want at least minimal, probably standard.
    – ephemient
    Mar 26, 2012 at 15:29
  • 1
    Wow, thanks! :) In the end, I did the unthinkable (don't try this at home) - I removed /var/lib/dpkg, /var/lib/apt, and /var/cache/apt. In the chroot, I installed the required files. Then from the debootstrap chroot, I copied those folders to the main system. From there things will work!
    – Albert H
    Mar 29, 2012 at 16:19
  • One last question - now I have a clean package DB slate, but that means any programs that were still installed now don't have packages attached to them. What should I do to restore the packages from examining my system file list? (If there's no automated tool, I'm fine with just knowing what tools I should use to look up the packages - I can write a BASH script to automate the process for me.)
    – Albert H
    Mar 30, 2012 at 2:56
  • @AlbertH apt-file can look up which packages files belong to.
    – ephemient
    Mar 30, 2012 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.