Why doesn't /etc/fstab use XML or JSON?

/etc/fstab is much older than XML and JSON, and as quite a lot of programs use it changing its format would be a nightmare.

Besides this /etc/fstab needs to be parsed before there is a functional system as it is used to mount all essential file systems. Hence the format of /etc/fstab should be as simple as possible as the parser should not depend on any external libs.

Parsing XML is quite difficult and you really want to avoid it if you can't relay on external libs. JSON is a bit easier but still quite difficult.

The semantics of /etc/fstab are quite simple, they don't include any tree-like data structures or any other fancy stuff. All you need is records consisting of six values.

Whitepace-separated values are good enough for that, and they are easy to parse even if all you have is the C standard libs.

So there's just no reason to use JSON, XML or something similar.


You should really read Eric Raymond's The Art of Unix Programming sometime. You seem to be making the assumption that the Unix designers would have used XML for /etc/fstab if they had known about it. On the contrary, although XML specifically had not been invented, they were quite aware of its similar predecessors, and deliberately rejected them for configuration files like /etc/fstab.

Quoting from his subsection on XML:

XML is well suited for complex data formats (the sort of things for which the old-school Unix tradition would use an RFC-822-like stanza format) though overkill for simpler ones. It is especially appropriate for formats that have a complex nested or recursive structure of the sort that the RFC 822 metaformat does not handle well.

and farther down:

The most serious problem with XML is that it doesn't play well with traditional Unix tools. Software that wants to read an XML format needs an XML parser; this means bulky, complicated programs. Also, XML is itself rather bulky; it can be difficult to see the data amidst all the markup.

The Unix philosophy is to make configuration easily scriptable and human readable wherever possible. You should be able to process config files with tools like awk, grep, sed, tr, and cut, and easily parse them in scripting languages without bulky libraries. This is a huge reason behind Unix's success and should not be underestimated.

Although Eric Raymond praises XML for its ability to handle "formats that have a complex nested or recursive structure," /etc/fstab certainly has no need for those, and therefore the simplest file format possible was chosen for it.

So although XML certainly has its uses, you might want to consider that some of the smartest programmers on the planet who pioneered the field might have known what they were doing. Perhaps XML isn't always the best fit for your own configuration files.


The main reason at which I can think now is:

  • The fstab file is most commonly used by the mount command
  • The history of mount command started probably before 1985
  • XML became a W3C Recommendation on February 10, 1998