Your best option is to add at least two large-ish drives (e.g. 4TB or more) and use some form of RAID-1 or RAID-10 - if you don't have any storage redundancy in your "mission critical" service, you're doing it wrong.
If you add only two drives, use RAID-1. for four or more use RAID-10. I would advise against using RAID-5 or RAID-6 for mail because mail storage needs a LOT of I/O bandwidth, and RAID-5 is much slower than RAID-1/RAID-10 (and RAID-6 is even slower).
There are multiple ways of implementing RAID-1/RAID-10, including mdadm
, and lvm
. With either of these, you can create a RAID array, format it with your preferred filesystem, and mount it in place of /var/mail
. You can also add more drives as needed in future, as long as your filesystem supports growing (e.g. xfs has xfs_growfs
, ext2/3/4 has resize2fs
).
Another option is to use btrfs
. This has built-in support for RAID-like features, and automatically grows the filesystem when you add more storage drives to it. It also supports error-detection and correction, snapshots, sub-volumes, transparent file compression, and more.
ZFS has similar features to btrfs (and is what I personally use) but has the disadvantage that it's not (and will probably never be due to license incompatibility between CDDL and GPL) a part of the mainline kernel. It's only available as a patch or DKMS module. That's not a big deal these days, but it IS more work.
My recommendation would be to use either btrfs or zfs. IMO there's not really any good reason to use plain old mdadm or lvm these days unless you're already using it and have significant experience and investment in the technology.
There are numerous questions and answers on this site that detail how to set up mdadm, lvm, btrfs, and/or zfs and others.
Anyway, no matter how you implement your RAID or RAID-like filesystem, you'll have to transfer your old mail to the new filesystem with a minimum of downtime. In all cases, the procedure will be a lot like this:
install the new drives. If you don't have hot-swap bays this will require some down-time.
set up the new raid and/or filesystem
mount it as /var/mail.new
rsync /var/mail/
to /var/mail.new/
You can repeat step 4 as often as you like until you have time to complete this procedure (probably best done out of business hours). Aside from some possible downtime in step 1, there should be no user-visible downtime up to this point....at most, they may have noticed the system is a bit slower than usual while the rsync
jobs are running.
stop your MTA (sendmail, exim, postfix, or whatever) and your pop/imap daemons, and anything else that writes to /var/mail/
. If you have any users who login to a shell to read mail (e.g. with mutt), tell them to log out and don't let them login again until you've finished.
In short, you need to stop anything and everything that writes to any file in /var/mail
. You'll restart them later in step 13.
run a final rsync
from /var/mail/
to /var/mail.new/
to sync any changes since the last run.
mv /var/mail /var/mail.old
mkdir /var/mail
unmount /var/mail.new
and re-mount it as /var/mail
(perhaps with mount --move /var/mail.new /var/mail
as mentioned by Austin Hemmelgarn)
examine the ownership and permissions of /var/mail.old
and make sure that /var/mail
has exactly the same.
This is easily done with:
chmod --reference=/var/mail.old /var/mail
(note --reference
requires GNU's version of chmod
, which is standard on linux)
edit /etc/fstab
so that the new filesystem is always mounted as /var/mail
after a reboot
you can now restart your MTA, pop and imap services and allow users to login again. monitor it very closely to make sure it's working correctly.
at your leisure, when you're sure that the new setup is working fine and you won't need the old mail directory any more, you can delete /var/mail.old
and all its contents.
BTW, you'll end up with over 1TB free in /var
after doing this. This may be excessive for your needs.