I have a machine that needs to have two configurations that I need to maintain (the machine is occasionally moved between two environments and has different roles in each environment).

Note: This is not an enterprise environment, it is a home environment.

I am considering a VCS (I like git), probably using etckeeper. However I realise that my toolbox is limited and that my VCS hammer might cause this problem to be identified as a nail when it could be identified better as something else.

Is this the correct way to go about the solution?

3 Answers 3


You have several alternatives to solve your problem:

  • use a VCS and make sure that permissions and ownership information of files are tracked as well
  • use a KVM instance for your second environment, i.e. you can install a 2nd Linux instance there in case you have enough hard disk space
  • setup a dual-boot configuration, such that you install a linux system for the first environment on partition X and a linux system for 2nd one on partition Y

What you choose is a matter of taste and depends on details of your environments. Perhaps your CPU does not support virtualization, space is on issue or you don't want to reboot the machine when moving to another environment.


You can take a look to switchconf that is designed specially to handle multiple /etc configurations and switching from one to another when needed.

You'll have to create 2 configurations in the /etc/switchconf directory, let's call them entreprise and home. In each directory, you'll have to create the etc subdirectories in which you need to change configuration files, and store into the files, e.g. :

/etc/switchconf/enterprise/etc/network/interface  # in which you store your enterprise network interface configuration

/etc/switchconf/home/etc/network/interface   # in which you store your home network interface configuration

If you need some scripts to be executed before or after switching the configuration, you can store them in /etc/switchconf/before.d and /etc/switchconf/after.d.

Finally, to switch from one configuration to another, just launch switchconf enterprise to use the entreprise configuration or switchconf home to use home configuration.


For a machine that needs to be moved between environments, I'd try to have a single set of files for /etc, with as much of the changing configuration as possible set dynamically with shell scripts. For example, the network configuration is probably different, so use a mapping directive in /etc/network/interfaces or conditionals in scripts in /etc/network/if-up.d and siblings.

If some static files need to change, keep two sets in two different directories, e.g.

/etc/configurations/current -> work
/etc/X11/xorg.conf -> /etc/configurations/current/xorg.conf

That way, you switch between configurations by changing the /etc/configurations/current symbolic link and restarting affected the services.

You may be able to leverage mechanisms that already exist in some subsystems, such as PCMCIA schemes.

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.