Choosing Between Maildir and sdbox Storage for Dovecot Deployments
Learn how to choose between Maildir and sdbox storage in Dovecot to prevent inode exhaustion in high-volume mail environments.
07 Aug 2026, 00:08 UTC

The Inode Exhaustion Problem
When scaling a Dovecot mail server, the primary technical constraint is often not disk space, but inodes. An inode is a data structure on a Unix-style filesystem that stores metadata about a file. Because every single email in a standard Maildir is stored as a unique file, a server with millions of small emails can run out of inodes long before the disk is full.
If you are deploying a server for a few hundred users, the simplicity of Maildir is usually sufficient. However, for high-density environments or filesystems with strict inode limits (like some EXT4 configurations), you must decide between the standard Maildir format and the sdbox (also known as dirbs) optimization.
Storage Format Comparison
| Feature | Maildir | sdbox (dirbs) |
|---|---|---|
| File Structure | 1 Email = 1 File | Multiple Emails = 1 File |
| Inode Usage | High (Linear growth) | Low (Compressed growth) |
| Concurrent Access | Excellent (No locking) | Good (Managed by Dovecot) |
| Backup Granularity | Per-message | Per-box/chunk |
| Performance | Fast for small mailboxes | Fast for massive mailboxes |
Evaluating the Trade-offs
When to use Maildir
Maildir is the industry standard for reliability. Because it avoids the complex locking mechanisms of the older mbox format, it is highly resistant to corruption. It is the correct choice if your filesystem has a high inode-to-disk ratio or if you rely on external tools to manipulate individual email files directly on the disk without going through the IMAP protocol.
When to use sdbox
sdbox optimizes the Maildir concept by grouping messages into larger files. This drastically reduces the number of directory entries the kernel must track. Choose sdbox when:
- You are using a filesystem with a fixed, low inode limit.
- You observe slow directory listing performance (
lsorfind) in user mail folders. - You are managing thousands of users with high message counts.
The primary trade-off with sdbox is I/O overhead during deletions. When a single message is deleted from a grouped file, Dovecot must manage the internal space of that file, which can be more resource-intensive than simply unlinking a single file in Maildir.
Implementation and Validation
Storage formats are defined in the Dovecot configuration file (typically /etc/dovecot/conf.d/10-mail.conf). These changes require a restart of the Dovecot service to take effect.
Scenario A: Standard Maildir Configuration
To implement a standard Maildir setup, ensure the mail_location directive is set as follows:
# Edit /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/MaildirScenario B: sdbox Configuration
To implement sdbox for inode optimization, use the following directive:
# Edit /etc/dovecot/conf.d/10-mail.conf
mail_location = sdbox:~/MaildirVerification Process
To verify which format is active and measure the impact on your system, follow these steps:
- Check File Creation: Log in as a user or use root permissions to inspect the mail directory. In Maildir, you will see a
cur,new, andtmpfolder containing individual files for every email. In sdbox, you will see a more condensed structure of indexed storage files. - Monitor Inode Consumption: Run the following command on the partition hosting the mail storage:
This displays the percentage of used inodes. If you are migrating from Maildir to sdbox, you should see thedf -i /var/mailIUsedcolumn stabilize or grow much more slowly as new mail arrives.
Rollback and Migration
Changing the mail_location directive does not automatically convert existing emails. If you change the setting from maildir to sdbox, Dovecot will look for files in the new format and will not find your old emails.
To rollback: Revert the mail_location setting to the previous format and restart Dovecot. If you have already moved data using a migration tool, you must use that tool's reverse process to restore the individual file structure before reverting the config.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.