Migrating to Dovecot's mdbox Storage for High-Volume Mailboxes
Migrate from Maildir to Dovecot's mdbox storage to solve inode exhaustion in high-volume mailbox setups. Follow these steps for configuration, verification, and rollback.
12 Jul 2026, 18:40 UTC

Problem: Inode Exhaustion with Traditional Maildir
When managing thousands of user mailboxes, the traditional Maildir format creates one file per message. This quickly exhausts inodes on filesystems, especially with small messages. Dovecot's mdbox storage format solves this by storing multiple messages in a single file, dramatically reducing inode usage.
Prerequisites
- Dovecot 2.3+ installed and configured
- Root or sudo access to the server
- Backup of existing mail data before migration
- Available disk space equal to current mail storage size
Configuration Steps
- Stop Dovecot service to prevent mail delivery during migration:
sudo systemctl stop dovecot
- Update dovecot.conf to use mdbox format. Edit the configuration file:
mail_location = mdbox:~/mail
Replace
~/mailwith your actual mail storage path if different. - Create the mail directory structure with correct permissions:
sudo mkdir -p /var/mail/vhosts
sudo chown vmail:vmail /var/mail/vhosts
- Run the migration tool for each user. Dovecot provides
doveadmfor this:sudo doveadm migrate -u username mdbox:~/mail
Replace
usernamewith actual usernames or use a loop for bulk migration. - Restart Dovecot to apply changes:
sudo systemctl start dovecot
Verification Checks
After migration, verify the setup is working correctly:
- Check storage format by examining the mail directory:
ls -la ~/mail/
Look for
maildirfolderormdboxfiles instead of individual message files. - Verify mailboxes are accessible:
doveadm mailbox list -u username
This should list all mailboxes without errors.
- Test email delivery by sending a test message and confirming it arrives correctly in your mail client.
Important Considerations
Backup Strategy: Since mdbox aggregates multiple users' mail into fewer files, traditional per-user backups may need adjustment. Consider backing up the entire mail directory or individual mdbox files per user.
Recovery Implications: Filesystem corruption affecting an mdbox file could impact multiple users. Ensure you have recent backups before migration.
Performance Monitoring: Monitor inode usage before and after migration to confirm the expected reduction. Use df -i to check inode consumption.
Rollback Procedure
If migration fails or causes issues, rollback is possible but requires careful steps:
- Stop Dovecot again:
sudo systemctl stop dovecot
- Revert mail_location in dovecot.conf to the original Maildir or mbox format:
mail_location = maildir:~/Maildir
- Restore from backup if the migration tool corrupted any data
- Restart Dovecot and verify service is operational
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.