Empowering Mail Server and slightly surreal Exim performance
Posted: January 5th, 2023, 9:19 pm
Empowering Mail Server and slightly surreal Exim performance
Few years ago...
My mail server Tweaked with Preserving the RAM disk through a Reboot.
Sometimes a server has to be shut down for servicing and you don't want to lose the email in the ram disk spool.
Here's a simple (Red Hat Linux-flavoured) script,
"exim-save", that I've installed as a service that backs up the queue to hard disk and restores it upon reboot.
Add the line with this:
I've installed it in the /etc/init.d/exim-save directory as a service and activate it by running:
And Now...
A Better Solution is... tmpfs
Instead of using a ramdisk, rather use tmpfs, supported by Linux kernel 2.4 and up.
The benefit of using tmpfs is... that memory is dynamically assignable, making it a far more flexible solution than ramdisks.
Additionally...
If your tmpfs partition runs out of space, the kernel will automatically begin paging data to your hard disk,
whereas the ramdisk solution would simply cause Exim to stop processing messages and crash.
Using tmpfs, you won't need to do any of the of the steps required for the above ramdisk solution.
The following steps are required for a successful tmpfs configuration:
Create a mountpoint and set correct permissions:
Next, open your /etc/fstab file and set the tmpfs partition to be created and mounted at boot:
This will create a 1GB tmpfs partition with 10'000 inodes.
The exim configuration is the same as when creating a ramdisk - either tell Exim that the location of the new spool directory is located at:
/mnt/tmpfs
or
bind the existing spool directory to the mountpoint:
/mnt/tmpfs
Alternatively, you could just mount the tmpfs partition onto Exim's existing spool directory right from the start - so instead of the above changes to the /etc/fstab file, use this line instead:
Next, open your /etc/fstab file and set the tmpfs partition to be created and mounted at boot:
or
Checked within 103 RBL's
(You might need to open this image in the new tab for sure)
(Pointing you cursor tho the image below, right click the image option, and choose open the image in the new tab, click the image to maximize)

Few years ago...
My mail server Tweaked with Preserving the RAM disk through a Reboot.
Sometimes a server has to be shut down for servicing and you don't want to lose the email in the ram disk spool.
Here's a simple (Red Hat Linux-flavoured) script,
"exim-save", that I've installed as a service that backs up the queue to hard disk and restores it upon reboot.
Code: Select all
nano /etc/init.d/exim-save
Code: Select all
# Preserving the RAM disk through a Reboot
# exim-save
# This shell script takes care of starting and stopping exim
#
# chkconfig: 2345 79 31
# description: Exim Save Data
# Source function library.
./etc/init.d/functions
[ -f /usr/sbin/exim ] || exit 0
start() {
touch /var/lock/subsys/exim-save
if [ -d /var/spool/exim-backup ]
then
cp -a /var/spool/exim-backup/*
/var/spool/exim/
rm -Rf /var/spool/exim-backup
fi
}
stop()
{
rm -f /var/lock/subsys/exim-save
if ! [ -d /var/spool/exim-backup ]
then
rm -Rf /var/spool/exim/db
rm -Rf /var/spool/exim/scan
rm /var/spool/exim/*.pid
cp -a /var/spool/exim
/var/spool/exim-backup
rm -Rf /var/spool/exim/input
fi
}
restart()
{
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $
"Usage: $0 {start|stop|restart}"
exit
1
esac
exit $RETVAL
Code: Select all
chkconfig exim-save on
A Better Solution is... tmpfs
Instead of using a ramdisk, rather use tmpfs, supported by Linux kernel 2.4 and up.
The benefit of using tmpfs is... that memory is dynamically assignable, making it a far more flexible solution than ramdisks.
Additionally...
If your tmpfs partition runs out of space, the kernel will automatically begin paging data to your hard disk,
whereas the ramdisk solution would simply cause Exim to stop processing messages and crash.
Using tmpfs, you won't need to do any of the of the steps required for the above ramdisk solution.
The following steps are required for a successful tmpfs configuration:
Create a mountpoint and set correct permissions:
Code: Select all
mkdir /mnt/tmpfs
chown -R mailnull:mail /mnt/tmpfs
Code: Select all
#<fs> <mountpoint> <type> <opts> <dump/pass>
tmpfs /mnt/tmpfs tmpfs size=1G,nr_inodes=10k,mode=0700 0 0
The exim configuration is the same as when creating a ramdisk - either tell Exim that the location of the new spool directory is located at:
/mnt/tmpfs
or
bind the existing spool directory to the mountpoint:
/mnt/tmpfs
Alternatively, you could just mount the tmpfs partition onto Exim's existing spool directory right from the start - so instead of the above changes to the /etc/fstab file, use this line instead:
Next, open your /etc/fstab file and set the tmpfs partition to be created and mounted at boot:
Code: Select all
#<fs> <mountpoint> <type> <opts> <dump/pass>
tmpfs /var/spool/exim tmpfs size=1G,nr_inodes=10k,mode=0700 0 0
Code: Select all
#<fs> <mountpoint> <type> <opts> <dump/pass>
tmpfs /var/spool/exim tmpfs size=2G,nr_inodes=1024k,mode=0700 0 0
(You might need to open this image in the new tab for sure)
(Pointing you cursor tho the image below, right click the image option, and choose open the image in the new tab, click the image to maximize)
