Volatiles: How to handle the /var directory

The /var directory is for storing volatile information, that is information which is constantly changing and which in general may be easily recreated. In embedded applications it is often desirable that such files are not stored on disk or flash for various reasons including:

For these reasons many of the OpenEmbedded distributions use a tmpfs based memory filesystem for /var instead of using a disk or flash based filesystem. The consequence of this is that all contents of the /var directory is lost when the device is powered off or restarted. Therefore special handling of /var is required in all packages. Even if your distrubution does not use a tmpfs based /var you need to assume it does when creating packages to ensure the package can be used on those distributions that do use a tmpfs based /var. This special handling is provided via the populate-volatiles.sh script.


If your package requires any files, directories or symlinks in /var then it should be using the populate-volatiles facilities.

Declaring volatiles

This section is to be completed.

  • how volatiles work

  • default volatiles

  • don't include any /var stuff in packages

  • even if your distro don't use /var in tmpfs, others do

  • updating the volatiles cache during install

Logging and log files

As a consequence of the non-volatile and/or small capacity of the /var file system some distributions choose methods of logging other than writing to a file. The most typical is the use of an in-memory circular log buffer which can be read using the logread command.

To ensure that each distribution is able to implement logging in a method that is suitable for its goals all packages should be configured by default to log via syslog, and not log directly to a file, if possible. If the distribution and/or end-user requires logging to a file then they can configured syslog and/or your application to implement this.


In summary the following are required when dealing with /var:

  • Configure all logging to use syslog whenever possible. This leaves the decision on where to log upto the individual distributions.

  • Don't include any /var directories, file or symlinks in packages. They would be lost on a reboot and so should not be included in packages.

  • The only directories that you can assume exist are those listed in the default volatiles file: packages/initscripts/initscripts-1.0/volatiles.

  • For any other directories, files or links that are required in /var you should install your own volatiles list as part of the package.