Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running Ubuntu 12.04 which has grown messy over the years. I have fiddled with various packages, desktop environments (for VNC) etc. and I would like to reinstall it to start again, and have better control over what goes into the box.

But I want to keep much of the configurations after reinstallation, like LVM configuration, apache2, samba, etc etc. There would ideally exist a program which could analyze /etc, installed packages and such, store the information, and selectively put it back into the new installation.

I am even considering installing Ubuntu server on a virtual machine, just to be able to compare the contents of /etc with a clean installation, and even perform a migration to the virtual machine first, to verify that the transfer process works.

How do one go about performing this kind of reinstallation? Have anyone seen any resources on the net on the topic?

share|improve this question

migrated from Sep 12 '12 at 16:50

This question came from our site for computer enthusiasts and power users.

etckeeper is what you're looking for.

UPDATE Thu Sep 13 16:41:44 ICT 2012

I do already have etckeeper in place, but I want to selectively restore parts to /etc

Sure, you can do it by using sparse checkout feature in Git 1.7.0.


cd /etc
git init
git remote add -f origin git+ssh://<server_name>.git
git config core.sparseCheckout true
echo 'path/to/subdir/*' >.git/info/sparse-checkout
git checkout <branch_name>

Don't forget to include a * character at the end of the path, otherwise you will get:

error: Sparse checkout leaves no entry on working directory
share|improve this answer
Yup - about the only thing that won't cover is LVM (you'll have to rebuild that yourself), but that's pretty trivial. Make sure to take a backup (of at least /etc and your home directories) before blowing the machine away in case you accidentally delete something etckeeper didn't catch. – voretaq7 Sep 12 '12 at 16:55
I do already have etckeeper in place, but I want to selectively restore parts to /etc. Should I merge from the backup? Also, all non-system data are on separate partitions, so no worries there. – Gunnar Sep 12 '12 at 17:53
@Gunnar: updated my answer. – quanta Sep 13 '12 at 9:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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