Directory - dir
¶
The directory storage driver is a basic backend that stores its data in a standard file and directory structure. This driver is quick to set up and allows inspecting the files directly on the disk, which can be convenient for testing. However, LXD operations are not optimized for this driver.
dir
driver in LXD¶
The dir
driver in LXD is fully functional and provides the same set of features as other drivers.
However, it is much slower than all the other drivers because it must unpack images and do instant copies of instances, snapshots and images.
Unless specified differently during creation (with the source
configuration option), the data is stored in the /var/snap/lxd/common/lxd/storage-pools/
(for snap installations) or /var/lib/lxd/storage-pools/
directory.
Quotas¶
The dir
driver supports storage quotas when running on either ext4 or XFS with project quotas enabled at the file system level.
Configuration options¶
The following configuration options are available for storage pools that use the dir
driver and for storage volumes in these pools.
Storage pool configuration¶
Key: | rsync.bwlimit |
Type: | string |
Default: |
|
When rsync
must be used to transfer storage entities, this option specifies the upper limit
to be placed on the socket I/O.
Key: | rsync.compression |
Type: | bool |
Default: |
|
Tip
In addition to these configurations, you can also set default values for the storage volume configurations. See Configure default values for storage volumes.
Storage volume configuration¶
Key: | security.shifted |
Type: | bool |
Default: | same as |
Condition: | custom volume |
Enabling this option allows attaching the volume to multiple isolated instances.
Key: | security.unmapped |
Type: | bool |
Default: | same as |
Condition: | custom volume |
Key: | size |
Type: | string |
Default: | same as |
Condition: | appropriate driver |
Key: | snapshots.expiry |
Type: | string |
Default: | same as |
Condition: | custom volume |
Specify an expression like 1M 2H 3d 4w 5m 6y
.
Key: | snapshots.pattern |
Type: | string |
Default: | same as |
Condition: | custom volume |
You can specify a naming template that is used for scheduled snapshots and unnamed snapshots.
The snapshots.pattern
option takes a Pongo2 template string to format the snapshot name.
To add a time stamp to the snapshot name, use the Pongo2 context variable creation_date
.
Make sure to format the date in your template string to avoid forbidden characters in the snapshot name.
For example, set snapshots.pattern
to {{ creation_date|date:'2006-01-02_15-04-05' }}
to name the snapshots after their time of creation, down to the precision of a second.
Another way to avoid name collisions is to use the placeholder %d
in the pattern.
For the first snapshot, the placeholder is replaced with 0
.
For subsequent snapshots, the existing snapshot names are taken into account to find the highest number at the placeholder’s position.
This number is then incremented by one for the new name.
Key: | snapshots.schedule |
Type: | string |
Default: | same as |
Condition: | custom volume |
Specify either a cron expression (<minute> <hour> <dom> <month> <dow>
), a comma-separated list of schedule aliases (@hourly
, @daily
, @midnight
, @weekly
, @monthly
, @annually
, @yearly
), or leave empty to disable automatic snapshots (the default).
Storage bucket configuration¶
To enable storage buckets for local storage pool drivers and allow applications to access the buckets via the S3 protocol, you must configure the core.storage_buckets_address
server setting.
Storage buckets do not have any configuration for dir
pools.
Unlike the other storage pool drivers, the dir
driver does not support bucket quotas via the size
setting.