Which directories in Linux must be part of the root filesystem?

Nick Coons asked:

I’m building a few virtual machines under KVM where the base system will be an image (haven’t decided specifically which format yet), and all of the remaining system files will be other partitions mounted from a distributed file system.

For instance, / will be part of the main image, but /home will be mounted from elsewhere. My goal is to keep the base system image as small as possible and thus to have as much of the system not be a part of the root partition.

So my question is: Which directories in Linux must be part of the root file system? For instance, I assume that directories such as /etc and /sbin must, because that’s where the utilities are that allow booting the system and mounting other partitions. But /opt can certainly be on a different partition.

In case it matters, the systems I’m building will either be Ubuntu Server 12.04 or perhaps 14.04 if I wait until it comes out before producing and deploying these.

My answer:

I recommend you not try a design like this unless you are using a very recent Linux system which has completed the /usr move. You’ll run into a variety of issues otherwise, the primary one being that packaged binaries are split between the shared filesystem and the unique per-machine filesystems. This completely negates any benefit you may have been aiming for by sharing a filesystem.

In any case, on a system post /usr move, the root filesystem pretty much holds mountpoints, symlinks to mountpoints and /etc and is otherwise empty; it can therefore be trivially small. Such a system contains no packaged binaries at all; everything is under /usr.

(This works on modern Linux systems because of the initramfs, which does the work of mounting filesystems necessary for booting.)

Notably, Ubuntu has not done the /usr move and it probably won’t happen until after systemd goes in. It will miss 14.04 LTS and I wouldn’t reasonably expect it until 16.04 LTS, if Ubuntu lives that long. I’m not sure why you’re set on Ubuntu, but I would seriously consider another distribution (and not only for this reason).

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.