1

Aside from the kernel itself, the Filesystem Hierarchy Standard is perhaps the only major feature common to all linux systems. Some obscure distributions modify it only slightly: stali, for example, uses a simplified version, while nixos adds too it (leaving /etc and /bin out of sight and out of direct control). Both, however, have a "/etc." You can swap out your init system, change your PATH, replace glibc with musl, pick a different window manager, desktop environment, display server, compositor, etc... But if you sit down at a running working linux machine, "/etc" will be there. You can be sure of that.

Which begs the question. What if you wanted to put it somewhere else...

In how many places, at how many levels, is the assumption of "/etc" made.

Does the kernel assume it's existence?

GLibc certainly has "/etc/hosts" hard-coded in the source. How many of these paths are there in glibc? Is there a list somewhere? How hard would if be to change them?

How much of the software on a bare bones embedded linux image is looking in there? How would we find out? Could we change it without recompiling? And then, how much more is there in, for example, Ubuntu, that would have to be changed?

Incidentally, I recall one of the first things I wanted to do when I first installed Ubuntu 10 years ago was to move /etc to /conf, I quickly discovered it didn't work like that. But if the Linux ecosystem were set up to make such a thing feasible, what might that look like?

This is a general curiosity, I'm asking in order to better understand the details of the linux ecosystem. Of course I'm not expecting a complete answer, but I figure someone might have some useful information or could point me in the right direction.

2
  • Ok.. but why? ^^
    – Bonsi
    Oct 14, 2020 at 7:35
  • Note that /etc and most of the other directories in that standard are common to all Unixes. Oct 14, 2020 at 16:03

2 Answers 2

3

Does the kernel assume it's existence?

No; the kernel assumes very little about the contents of the file systems it’s used with. The kernel will look for /etc/init in some circumstances (along with /sbin/init etc.), and a few staging drivers use helpers in etc, but the kernel will work fine without /etc.

GLibc certainly has "/etc/hosts" hard-coded in the source.

Yes, it does.

How many of these paths are there in glibc? Is there a list somewhere? How hard would if be to change them?

In my copy of the repository, grep -r '"/etc' finds 86 instances. I’m not aware of a maintained list anywhere. Changing the paths in the source code isn’t too hard.

How much of the software on a bare bones embedded linux image is looking in there?

That’s harder to determine. Programs which expect their own configuration in /etc will certainly look there; many others will indirectly, through libraries, if only the C library. The former would require changes to use another path; the latter would pick up any changes made to the libraries in question.

How would we find out?

grep... See also the corresponding source code search in Debian.

Could we change it without recompiling?

No. A related question is how much change would be involved before recompiling. Autoconf-produced configure scripts often support a sysconfdir option which defaults to /etc or /usr/local/etc, but that doesn’t handle all situations — in many cases it determines where a program installs and looks for its own configuration files, but it won’t change where a program looks for other files it expects in /etc (see the GNU C library).

And then, how much more is there in, for example, Ubuntu, that would have to be changed?

Less and less as you move further “up the stack”, I suspect. Anything user-configurable will have at most defaults in /etc, and many programs nowadays don’t have any configuration in /etc at all, or if they do it’s provided through some mechanism other than looking directly in /etc.

But if the Linux ecosystem were set up to make such a thing feasible, what might that look like?

It might look like one of the freedesktop.org specifications which determine how programs find files (XDG etc.).

1

You are asking about Gnu/Linux (Linux is the kernel, also often confusingly used to describe the whole OS. As OS is a kernel, shell, command tools, libraries, and a compiler — I think that this may have been dennis ritchie that said this. You can have Linux without GNU: android, and Gnu without Linux: cygwin, Windows Subsystem for Linux 1, Gnu/Hurd, Gnu on BSD, Gnu on Solaris, …)

Back to your question

Just recompile every single program to look for config in a different place.

Any program that uses auto-conf, can easily be compiled with different locations. There can be good reasons for this. But why change the default.

Alternatively all a symlink from /conf to /etc. (cd /; ln -s -T /etc /conf )

5
  • Android is a good counter example, although it looks like typically there is at least a symlink at /etc (pointing to /system/etc), presumably for compatibility with software that expects it to exist.
    – segfault
    Oct 13, 2020 at 22:46
  • Can you give an example for how to give auto-conf a different path? Is there some standard way of configuring paths or is it just however the project devs made the build config?
    – segfault
    Oct 13, 2020 at 22:53
  • When one compiles a program that uses autoconf, one runs ./configure this can take an argument to state what the install dirs will be. e.g. prefix to change the root. see gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/… Oct 14, 2020 at 9:26
  • That will change the install dir, will it change where the program looks for /etc ?
    – segfault
    Oct 14, 2020 at 14:16
  • Yes. From what I remember. It has to be in there somewhere, and from what I remember, prefix will affect all directories. There are other options to do finer tuning (just /etc but not other hard-coded directories ). Oct 14, 2020 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .