|
| 1 | +Middleware State Directories |
| 2 | +############################ |
| 3 | + |
| 4 | +.. contents:: Table of Contents |
| 5 | + :depth: 4 |
| 6 | + |
| 7 | +The middlewared process stores state in several directories on the local filesystem. There |
| 8 | +are many situations in which the developer may opt to store state information outside of the |
| 9 | +configuration database. In this case the onus is on the developer to choose an appropriate |
| 10 | +location for this state based on persistence requirements. |
| 11 | + |
| 12 | + |
| 13 | +Volatile state |
| 14 | +************** |
| 15 | + |
| 16 | +Volatile middleware state is stored in the middleware run directory `/var/run/middleware`. |
| 17 | +The expected permissions on the volatile state directory are 0o755. This is typically where |
| 18 | +sentinel files should be placed. This is defined by `MIDDLEWARE_RUN_DIR` in `middlewared/utils`. |
| 19 | + |
| 20 | + |
| 21 | +Persistent state |
| 22 | +**************** |
| 23 | + |
| 24 | +There are several directories that are used to store persistent state related to the middlewared |
| 25 | +process and TrueNAS servers. |
| 26 | + |
| 27 | +`/data` -- this ZFS dataset contains the TrueNAS configuration file `freenas-v1.db` and various install-specific |
| 28 | +configuration files that must persist across TrueNAS upgrades. Items that need to be included in the configuration |
| 29 | +tarball should generally be placed here. Permissions on this directory must be 0o755, but many files here should |
| 30 | +be set to 0o700. All files and directories should be owned by root:root. |
| 31 | + |
| 32 | +`/data/subsystems` -- this directory contains application-specific configuration that must persist between |
| 33 | +installs that is not suitable for datastore insertion. The convention is to create a new directory with the name of |
| 34 | +the middleware plugin that needs persistent state. Configuration information stored in these directories must be |
| 35 | +included in the TrueNAS configuration backup and restored on configuration upload. |
| 36 | + |
| 37 | +`/var/lib/truenas-middleware` -- this directory contains persistent middleware state that is applicable to the |
| 38 | +current boot environment only. It is a safe place to store data that we want to persist across reboots, but not |
| 39 | +across upgrades. This is defined by the `MIDDLEWARE_BOOT_ENV_STATE_DIR` in `middlewared/utils`. The permissions |
| 40 | +on this directory should be 0o755 and it should be owned by root:root. |
| 41 | + |
| 42 | +`/root` -- this dataset contains the middleware directory services cache. The permissions on this directory |
| 43 | +should be 0o700 and it should be owned by root:root. |
0 commit comments