Ubuntu – Where in the filesystem should I store shared data

filesystem

Where in the unix filesystem is the conventional location to save non-user specific data, for example data shared via nfs or ftp, or backups?

I could obviously create and use any arbitrary folder (such as /home/shared, /data or /var/data), but I'm really wondering if there are any "best" or "common" practice guidelines. The Filesystem Hierarchy Standard doesn't specify a location for shared data.

For backups, I tend to use /var/backups, but as several cronjobs write to it should it really be left for their use?

Best Answer

This question does seem to have a clear answer in the Filesystem Hierarchy Standard, which specifies /srv as "contain[ing] site-specific data which is served by this system ". (3.16.1)

This main purpose of specifying this is so that users may find the location of the data files for particular service, and so that services which require a single tree for readonly data, writable data and scripts

(my emphasis)

Note: 'Served by the system' doesn't necessarily refer to the Internet. It needn't even mean a network. It's applicable to even a shared system. Further, the words site and service should be understood in their pre-internet meanings. Your site can be "the physics department" or "the finances office".

It goes on to say:

On large systems it can be useful to structure /srv by administrative context, such as /srv/physics/www, /srv/compsci/cvs, etc. This setup will differ from host to host. Therefore, no program should rely on a specific subdirectory structure of /srv existing or data necessarily being stored in /srv. However /srv should always exist on FHS compliant systems and should be used as the default location for such data.

You should therefore further structure your data in directories such as /srv/nfs, /srv/backup and so on.

I should also mention that few people do this anymore. But there is no good reason why they don't. The standard is by no means out of date.

/var is traditionally used for things like print-spools and log-files, but it's also used by the Apache web server (on Debian systems anyway - SUSE use /srv); There doesn't seem to be consensus on whether /var is a proper directory for shared data. But if you decide to use it instead, you will have no regrets I'm sure.

Note also: Karthick's answer is by no means wrong. The FHS says /srv " should be used as the default location for such data", but the standard leaves some room for your own preference, depending on how you interpret the terms.

Related Question