Linux – How to switch between different Linux configurations

configurationetclinuxraspberry pi

I have several different use cases for my Raspberry Pi 3. Currently I have a configuration for it as a media centre, for streaming audio, for hacking purposes, office workplace, etc. All configurations are based on the default Raspbian distribution.

Those configurations require different (systemd) services and different /etc service config files. For example: my office workplace, I have Network Manager configured with as much wifi network passwords as I need, while for my hacking station, I'd like to disable Network Manager and configure a rotating mac address and static ip. Sometimes I like my Pi headless, and sometimes I need a GUI. Etc.

Key is, that not only the services differ, also the service config files differ, based on the purpose.

My question is: how do I "switch" between configurations (services+ config files) within the same Linux environment? Ideally I'd like to issue a (terminal) command to switch to another "mode".

Already tried:

  • Different partitions with multi boot grub: costs a lot of space/overhead. Does not accommodate easy switching.
  • Use runlevel to differentiate: does not accommodate different config files.
  • Create my own "switch script" that stops services, copies/switches config files and (re)starts services: comes close, but feels like I'm re-inventing the wheel.

Any suggestions for an "out-of-the-box" solution for this? I can't imagine I'm the first or only one with this need.

Best Answer

It sounds like creating targets in systemd, and possibly storing /etc/ in git would create something akin to what you want. Change target, switch git branch, you might want to have an intermediary target that disables most services before switching everything.

Related Question