cPanel reporting incorrect /mail/ directory size

Many times, cPanel is reporting an incorrect value in cPanel->Disk Usage interface for the /mail/ directory. In our test case the value from the shell is 308MB:

root@web [/home/mmtest]# du -sh mail
308M    mail
root@web [/home/mmtest]#

But the value reported in cPanel is 462.99MB as shown in the image below:

cpanel mail1
/mail/ directory size in cPanel – wrong value reported

This is caused by the dovecot server not updating correctly the disk usage. To fix this situation, run the commands:

# /scripts/generate_maildirsize --confirm --allaccounts --verbose $username

root@web [/home/mmtest]# /scripts/generate_maildirsize --confirm --allaccounts --verbose mmtest
Rebuilding the maildirsize files for: mmtest
Rebuilding the maildirsize files for: john@mmtest123.com
Checking user mmtest
Calculating diskusage and diskcount from reading files
Writing /home/mmtest/mail/maildirsize for user merches
Checking user john@mmtest123.com
Calculating diskusage and diskcount from reading files
Writing /home/mmtest/mail/mmtest123.com/john/maildirsize for user john
root@web [/home/mmtest]#

Now the disk usage is reported correctly in cPanel:

cpanel mail2
/mail/ directory size in cPanel – correct value

To run the command for all the accounts use

# /scripts/generate_maildirsize --confirm --allaccounts --verbose

More information on this cPanel script can be found by running

# /scripts/generate_maildirsize --help

Leave a Reply