This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.

dbox

dbox is Dovecot's own high-performance mailbox format. The original version was introduced in v1.0 alpha4, but since then it has been completely redesigned in v1.1 series and improved even further in v2.0.

dbox can be used in two ways:

  1. sdbox: One message per file (single-dbox), similar to Maildir. For backwards compatibility, "dbox" is an alias to "sdbox" in mail_location.

  2. mdbox: Multiple messages per file (multi-dbox), but unlike mbox multiple files per mailbox.

One of the main reasons for dbox's high performance is that it uses Dovecot's index files as the only storage for message flags and keywords. This means that indexes don't have to be "synchronized". Dovecot trusts that they're always up-to-date (unless it sees that something is clearly broken).

Unlike Maildir the message file names don't change. This makes it possible to support storing files in multiple directories or mount points. dbox supports looking up files from "altpath" if they're not found from the primary path. This means that it's possible to move older mails that are rarely accessed to cheaper (slower) storage.

dbox storage is extensible, so in future there will be other extensions. Some things that are planned:

Multi-dbox

You can enable multi-dbox with:

mail_location = mdbox:~/mdbox

The directory layout (under ~/mdbox/) is:

The storage directory has files:

Each m.* file contains one or more messages. mdbox_rotate_size setting can be used to configure how large the files can grow.

The map index contains a record for each message:

Mailbox indexes refer to messages only using map_uids. This allows messages to be moved to different files by updating only the map index. Copying is done simply by appending a new record to mailbox index containing the existing map_uid and increasing its refcount. If refcount grows over 32768, currently Dovecot gives an error message. It's unlikely anyone really wants to copy the same message that many times.

Expunging a message only decreases the message's refcount. The space is later freed in "purge" step. This may be done automatically within the session or later in a nightly cronjob when there's less disk I/O. The purging first finds all files that have refcount=0 mails. Then it goes through each file and copies the refcount>0 mails to other mdbox files (to the same files as where newly saved messages would also go), updates the map index and finally deletes the original file. So there is never any overwriting or file truncation.

The purging can be invoked explicitly running doveadm purge.

There are several safety features built into dbox to avoid losing messages or their state if map index or mailbox index gets corrupted: