Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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've had my workstation for a couple of years now and its slowly become a complex beast, taking on many roles for my dev and test work. I have done some research and was thinking of setting up some chroot environments to help keep things contained (web/app server, 32/64bit development env, etc...).

I'd like to configure this and migrate from the current setup, so I can make sure it all works before committing to the move. I would then like to reinstall my host OS. (A more recent version of Ubuntu as I'm on an older LTS release. I could reinstall the same version if it complicates things, I just want a clean host, as things have become a mess over time)

If I create the chroots on a mounted filesystem, can I reinstall the host OS, reconfigure chroot, mount the chroot directory and things work? Am I oversimplifying things?

Any information or links are very much appreciated.

share|improve this question
up vote 1 down vote accepted

If you install the OS inside a chroot in a directory deep in an existing filesystem, you won't be able to boot it without hassle. It's possible if you work on it, but it's not a good way to get a clean installation.

I recommend first making a clean installation in a system partition of its own. Shrink one of your existing partitions to make room. If you need to do that from outside your installed operating system, get SystemRescueCD or GParted Live.

After you've done the initial installation, you can start running the new installation in a chroot. When you're confident that it can do what you want, switch over to running your new installation. Mount your old installation somewhere and run your old programs in a chroot if necessary. Mount your data partitions under the new installation. Finally, relinquish the old installation.

For most services, you'll have to choose whether to run the service from the chroot and the service from the master installation. Running services in the chroot will be more complicated to arrange. Note that Ubuntu starts services when you install them with dpkg or APT, so if you do package installations in the chroot, you should disable that; see “Services in the chroot” in this answer for how to do that.

In your new installation, follow these recommendations to keep things clean:

  • Never manually modify a file under /bin, /sbin, /lib, /usr or /var, except that /usr/local is fair game.
  • Install the etckeeper package. All your changes in /etc will be tracked under version control (Bazaar by default). Changes will be committed automatically every night and every time you run APT by default, but strive to commit your changes manually with a meaningful message.
  • Make all modifications that are personal preferences and not intimately tied to the machine in your home directory, not in /etc.
  • If you need both a 64-bit environment and a 32-bit environment, this guide should help.
share|improve this answer
Perfect, lots of good info here. Thanks for the heads up on services starting at install under ubuntu. I better start reading, thanks again. – StillLearningCPP Feb 10 '12 at 5:18

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.