Store IMAP on a different disk?

Murfy

Verified User
Joined
Jan 4, 2015
Messages
5
What would be the easiest approach to store IMAP e-mail on a different disk?
We have servers running with SSD drives and regular drives and I would like to store the IMAP e-mail on the regular spinning drives.

I could set up symlink for every user, but I was wondering if there was an easier way to accomplish this?
 
Yes, I am aware of that, but every user has his own mail folder inside the home directory.. so I would have to manually change the location for every user.. can it be automated during creation of accounts?
 
No, when you mount /var (for example) to the SSD, your system will see it as any other disk. No need to change things manually.
 
I am aware of how mounting behaves, however there is a misunderstanding.

All e-mail is stored in /home/$user/mail (or something, it's IN the home folder anyway). I have SSD based storage where all the web files should reside for performance reasons. However the SSD disk is smaller than the "regular" storage (250 GB compared to 1 TB), and I don't need fast storage for e-mail, so I want ONLY the e-mail to be stored on the "regular" storage (1TB) instead of the SSD (250 GB).
 
You need to mount the SSD drive in a separate mountpoint and link emails folder to that disk with the user_create_post.sh script

Regards
 
I am aware of how mounting behaves, however there is a misunderstanding.

All e-mail is stored in /home/$user/mail (or something, it's IN the home folder anyway). I have SSD based storage where all the web files should reside for performance reasons. However the SSD disk is smaller than the "regular" storage (250 GB compared to 1 TB), and I don't need fast storage for e-mail, so I want ONLY the e-mail to be stored on the "regular" storage (1TB) instead of the SSD (250 GB).

There are two ways to go:

1. Use a separate partition for storing emails: /var/spool/virtual (1TB disk) for example. In this case exim.conf/dovecot.conf should be modified and some post/pre scripts should written to use this location.

2. Still use a separate partition for storing emails: /var/spool/virtual (1TB disk) for example and use mount to bind maildirs to homedirs. No need to change exim.conf/dovecot.conf. Still need to use some post/pre scripts.

In the both cases you might run into a quota issue when Directadmin won't count emails into user quota.

Please note, if you need somebody to do this setup for you please feel to contact any of us here who you'd trust more for a quote.
 
Alex, mails aren't now stored in /home/USER/imap using dovecot??

What do you mean? If you use Dovecot delivery with exim.conf 4.3.x then it's dovecot which puts all incoming emails into /home/USER/imap. If you use exim.conf 2.x then it's exim which puts incoming emails into users mailboxes in /home/USER/imap. Or I miss anything from your question?
 
You sayd to set as path /var/spool/virtual but as far as i know it should be /home/USER/imap

Why use the spool folder if mail will not be stored there?

Also,

In the both cases you might run into a quota issue when Directadmin won't count emails into user quota.

This should not be totally correct, since if you mount the partition with quotausr and quotagrp DA should be able to count them too since it should use quota command to count data amount, am i wrong?

Regards
 
Last edited:
If you want to mount a new HDD directly to /home/USER/imap you should have so many partitions on it as users you have there and probably forget about correct disk quotas.

so it would be:

/dev/sdb1 mount to /home/user1/imap
/dev/sdb2 mount to /home/user2/imap
/dev/sdb3 mount to /home/user3/imap
...
...
...
/dev/sdbN mount to /home/userN/imap

I wouldn't do that, this way it is difficult to maintain it unless use LVM.


So my point is to mount /dev/sdb1 (1Tb partition) to any place you want outside the /home, why not to /var/spool/virtual ?
Then you create there the following structure:

/var/spool/virtual/user1/imap
/var/spool/virtual/user2/imap
/var/spool/virtual/user3/imap
...
...
...
/var/spool/virtual/userN/imap

And depending on what way you want to go, either use mount --bind or modify exim.conf/dovecot.conf to work with imap folder located in /var/spool/virtual/.

This should not be totally correct, since if you mount the partition with quotausr and quotagrp DA should be able to count them too since it should use quota command to count data amount, am i wrong?

That's correct only partly. Directadmin will probably show quotas correct, but users will be able to overpass quota limit. If you have emails and a homedir on one and the same partition and a quota limit of 1Gb, you wont be able to overcome it much.

If you have imap folder on another partition how much quota you will set for an user there? Another 1Gb? Part of it? 100Mb? No limit at all? That of course depends on a hosting packages, so let them decide.
 
I do agree about a single partition but your post did sound to me that normal email folder was that.

My idea would be to mount the second disk to /email and than create /email/user/imap-strcture and just do symlink for each new user of /home/user/imap to /email/user/

That would prevent the need to edit confs file.

Regards
 
Digging up an old thread again but.. is there anything new related to this issue ?

We have the same issue of Terabytes of user mails stored on SSD..
And we also have the issue of backing all this up.

Having the possibility to tell directadmin to store emails in another location than /home/user/imap would be very interesting.
 
Will
Code:
mount --bind
do what you need?

Example

Code:
mount --bind /opt/drive2/user [COLOR=#333333]/home/user/imap
?[/COLOR]
 
For each of the 400+ users on the server ?

I was looking/hoping for a built in directadmin solution where eventually the directory structure would be duplicated for emails.
(so have : /home/user1..n/ for user data and /custompath/user1..n/ for user mail data)

I don't know if any of the control panels in the market propose such an option but with email storage increasing it will surely be needed at some point.
At the moment we provide 200 Go space for our customers and some of them have 150 Go of emails.. this is buring ssd space and also becoming a nightmare to backup..
 
A hook could do a lot of the hard work. The number of users wouldn't matter. I am not sure which hook would be the best fit though. I would probably go for user_create_post.sh. It should:

1. Create a new folder on the disk that has spinning disks.
2. Copy existing data from /home/USER/Maildir and /home/USER/imap.
3. Set permissions.
3. Create a symlink. Bind mounds need to be added to fstab to survive reboots. Not sure of the implications of symlinks, though.

I think that's about it.

But just like you I prefer this to be a feature in DirectAdmin. Apart from backups, we have exactly the same problem with e-mail taking up a lot of space.
 
If you need a native support from DirectAdmin feel free to contact developers via ticket and provide all pros on why it should be added.

I've provided a possible solution on how to do it now.

If I needed to set it up, I would use hooks as well, probably without symlinks and "mount --bind" as well. Though symlinks and "mount --bind" will work, it might be hard to maintain them with a big number of users.

In early days DirectAdmin used to store emails under /var/, then email storage was moved to /home/username/imap/

My idea is to modify storage location directly in /etc/virtual/domain.com/passwd and customize /etc/exim.conf
The /etc/virtual/domain.com/passwd file will need to be updated each time when you add/modify/delete email accounts.

Note, it's just a raw idea and I did not try any of it, so at this moment I might overlook some details.
 
Back
Top