Choosing Between Maildir and sdbox for Dovecot Mail Storage
Compare Maildir and sdbox storage formats in Dovecot to solve inode exhaustion and performance degradation in high-volume mailboxes.
11 Nov 2025, 15:14 UTC

The Storage Bottleneck: Inodes vs. Portability
When scaling a Dovecot mail server, the primary technical constraint is often the filesystem's inode limit—the maximum number of individual files the system can track. In a standard Maildir setup, every single email is a separate file. For a user with 100,000 emails, that is 100,000 inodes. On filesystems like ext4, this can lead to inode exhaustion or severe directory listing latency, even if disk space is plentiful.
The decision between Maildir and sdbox (Dovecot's optimized directory format) is a trade-off between universal compatibility and filesystem efficiency. The key takeaway is that sdbox solves the inode problem by grouping multiple messages into single files, while Maildir ensures that your data remains readable by almost any other mail utility without a conversion process.
Storage Format Comparison
| Feature | Maildir | sdbox (DirPal) |
|---|---|---|
| File Structure | One file per email | Multiple emails per file |
| Inode Usage | High (1:1 ratio) | Low (Optimized) |
| Portability | Universal/Standard | Dovecot-specific |
| Performance | Degrades with high file counts | Stable at high volumes |
| Reliability | High (No index corruption) | High (Uses internal indexing) |
Engineering Trade-offs
When to choose Maildir
Maildir is the safest choice for small to medium deployments or environments where data portability is a requirement. Because it follows a strict directory structure (typically cur/, new/, and tmp/), you can move mailboxes between different server software versions or vendors using simple file copy commands. Use Maildir if your users typically keep fewer than 10,000 messages per folder.
When to choose sdbox
Choose sdbox for high-density environments or when using filesystems with strict inode limits. By reducing the number of files the OS must track, sdbox minimizes the metadata overhead during IMAP searches and synchronization. This is critical for "power users" who archive hundreds of thousands of messages in a single folder, where a standard Maildir would cause the filesystem to hang during a ls or readdir operation.
Implementation and Configuration
The storage format is defined in the dovecot.conf file (or a separate 10-mail.conf file depending on your distribution). These changes require a Dovecot restart to take effect.
Configuring Maildir
To use standard Maildir, set the mail_location parameter. Run this as a user with root or sudo permissions on the mail server:
# Edit /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
Configuring sdbox
To use the optimized sdbox format, specify the sdbox prefix. Note that this is a Dovecot-specific implementation:
# Edit /etc/dovecot/conf.d/10-mail.conf
mail_location = sdbox:~/Maildir
Verification and Diagnostics
To verify which format is currently active and how it is impacting your system, use the following checks:
- Configuration Check: Run
dovecot -n | grep mail_locationto see the active setting. - Physical Inspection: Navigate to a user's mail directory. If you see
cur/,new/, andtmp/folders containing thousands of uniquely named files, you are using Maildir. sdbox will have a different internal structure optimized for Dovecot's index. - Inode Monitoring: Run
df -ion the mail partition. If theIUsed%is climbing rapidly while disk space remains high, you are likely hitting the limits of Maildir and should consider migrating to sdbox.
Migration and Rollback
Changing the mail_location in the config file does not automatically convert existing mail. To move from Maildir to sdbox, you must use the doveadm convert tool.
Risk Warning: Converting from Maildir to sdbox is generally a one-way operation. While you can technically move back, it requires a complex export and re-import process. Always perform a full filesystem snapshot before running conversion commands.
To convert a specific user's mailbox:
# Run as root/dovecot user
# Syntax: dovecadm convert -m [format] [user]
# Example: dovecadm convert -m sdbox [contact removed]
To roll back a configuration change (if no conversion was run), simply revert the mail_location string in 10-mail.conf and restart the service: systemctl restart dovecot.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.