Choosing Maildir vs sdbox for Dovecot: A Practical Decision Guide
Compare Maildir and sdbox storage formats in Dovecot to balance filesystem performance, inode usage, and interoperability for high-volume mail servers.
13 May 2026, 19:40 UTC

The Storage Bottleneck in High-Volume Mail Servers
When a Dovecot mail server handles thousands of messages, the filesystem becomes a performance choke point. Each directory entry requires a stat() system call, and the number of inodes consumed can limit scalability. The choice between the traditional Maildir layout and Dovecot’s sdbox format determines whether the server relies on universal file‑system compatibility or on an optimized, index‑driven structure.
Comparing Maildir and sdbox
| Feature | Maildir | sdbox |
|---|---|---|
| File Structure | One file per message | Messages grouped; index files manage lookup |
| Inode Usage | Very High | Low to Moderate |
| Interoperability | High (standardized) | Low (Dovecot‑specific) |
| Lookup Speed | Slower for large folders | Fast (index‑driven) |
| Recovery | Simple file copy | Requires index rebuilds |
Trade-offs and Decision Constraints
Select Maildir when you need raw file access for third‑party backup scripts, forensic analysis, or when the mailbox size stays below a few hundred thousand messages. Its flat file model avoids any dependency on Dovecot’s internal indexing, making recovery straightforward.
Choose sdbox for environments with very large mailboxes (tens of thousands to millions of messages) where directory listings become a noticeable CPU load. By grouping messages and maintaining a compact index, sdbox reduces the number of stat() calls and improves response time for folder synchronization and message retrieval.
In high‑volume environments, the number of inodes can become a limiting factor. Maildir’s per‑message file model consumes one inode per email, which can exhaust the inode quota on filesystems that allocate a fixed inode count (common on ext4 with default settings). When this occurs, new mail deliveries may be rejected even though disk space remains available. sdbox mitigates this issue by grouping messages, reducing the total inode count dramatically. Administrators should therefore monitor inode usage with df -i and consider the long‑term inode budget when selecting a storage format.
Implementation and Configuration
The storage format is defined by the mail_location directive in Dovecot’s configuration. Editing this file requires root or sudo privileges.
# Example sdbox configuration (requires root or sudo)
mail_location = maildir:~/Maildir:INDEX=~/mailindex
In most recent Dovecot versions (2.3+), the syntax above tells the server to treat the Maildir directory as the base while storing an auxiliary index in ~/mailindex. The index files are created automatically; no additional conversion step is needed beyond changing the configuration and restarting the service.
When converting an existing Maildir setup to sdbox, the recommended approach is to let Dovecot perform the migration automatically on first start after the configuration change. The server reads each Maildir file, creates the corresponding sdbox entries, and writes the new index files. No manual copy of the Maildir directory is required, but a backup of the original Maildir directory is advisable before the change, as the process rewrites the mail storage layout.
Validating the Storage Format
- Configuration Check: Run
doveconf mail_locationas a user with read access to the Dovecot configuration (usually the dovecot user). The output shows the activemail_locationstring. - Filesystem Inspection: SSH into the server and list a user’s mail directory. If you see
cur/,new/, andtmp/sub‑directories each containing a separate file per message, the server uses Maildir. If the directory contains.indexfiles and messages are stored in fewer, larger files or in grouped sub‑folders, sdbox is active. - Index Integrity: For sdbox deployments, verify the index with
doveadm index -u username@domain INBOX. The command must be executed with root or the dovecot user; a successful run without error indicates the index is synchronized with the physical storage.
In addition to manual checks, administrators can enable Dovecot’s built‑in health‑status commands, such as doveadm reload to refresh configuration without dropping connections, and doveadm dict to inspect dictionary lookups that may be affected by storage format changes.
Limitations and Rollback
The conversion from Maildir to sdbox is effectively one‑way. While Dovecot can import Maildir files into an sdbox layout, there is no built‑in automated tool to revert an sdbox structure back to a standard Maildir format. If the index files become corrupted, you may need to re‑index the entire mailbox, which can be time‑consuming.
Rollback Procedure: If changing mail_location causes the IMAP service to fail to start or mailboxes become invisible, revert the configuration to the previous value and restart Dovecot:
# Edit /etc/dovecot/conf.d/10-mail.conf (or the appropriate file)
# Change mail_location back to the original string
systemctl restart dovecot
After restart, verify with doveconf mail_location and a filesystem inspection to confirm the original layout is restored.
Practical Verification Checklist
- Confirm the active storage format via
doveconf mail_location. - Inspect the mail directory structure for Maildir vs sdbox characteristics.
- Run
doveadm indexon a sample mailbox to ensure index health. - Monitor inode usage (e.g.,
df -i) if you anticipate very large mailboxes.
Conclusion
In summary, choose Maildir for simplicity, broad compatibility, and smaller mailbox sizes where inode consumption is not a concern. Opt for sdbox when scaling to very large mailboxes, seeking lower CPU overhead during directory operations, and accepting the need to manage Dovecot’s index files. The decision ultimately hinges on balancing operational flexibility against I/O efficiency, and the configuration changes are straightforward once the storage format is selected.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.