1 (edited by redmuser 2023-11-26 04:10:02)

Topic: Storing iRedMail files (/var/vmail) on a network drive

First post here, so apologies for extra detail.

I am running a large highly redundant network storage shared with different VMs. I wanted to migrate my iRedMail server to a setup in which all files from /var/vmail directory are stored remotely on the network storage, rather than on a local drive. That would add redundancy and also provide access to a pooled storage resource, both massive advantages to me.

I tried attaching the storage via fstab adding the following statement

//<IP>/Shared\040iRedMail /var/vmail cifs user=iredmail,pass=<pass>,auto,users 0 0

but even though I am able to get most of the functions working, I am running into (I think) permission issues, showing up "Server Error: STATUS: Internal error occurred. Refer to server log for more info" red error box in the right bottom corner when trying to access any folders.

After fighting a few hours with the problem, I am not sure whether such a setup is even supported at all, since all subfolders in /var/vmail directory do not seem to have proper ownership and inherit the permission from /var/vmail mount.

Has anybody looked into such a setup and made it work? Any pointers would be really welcome.

Thank you!

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Storing iRedMail files (/var/vmail) on a network drive

I found this thread on the forum (https://forum.iredmail.org/topic17753-h … olume.html), which is similar, but involves a different local hard drive. That topic is closed, unfortunately.

3

Re: Storing iRedMail files (/var/vmail) on a network drive

I think I found my answer via Dovecot wiki page: wiki.dovecot.org/MailLocation/SharedDisk

    Samba / CIFS

    Dovecot's temporary files may include a colon character ':' in their filename, which is not a permitted character when using cifs. Dovecot also renames the temporary files whilst holding a lock in them, which generates the error 'Text file is busy'.

    Cifs/smbfs is unlikely to work as a remote filesystem.

I guess my plan of having it attached on a network share is going to fail big unless I have a way to not use cifs/samba. Off to more reading.

4

Re: Storing iRedMail files (/var/vmail) on a network drive

NFS seems to be the answer. It is odd that Dovecot would create such limitations. I will look into submitting a request to make it more SMB compatible. There is no good reason for using ":" symbols in the file names, really.

5

Re: Storing iRedMail files (/var/vmail) on a network drive

Even with the NFS shared folder, I am getting chown errors. I wonder whether it will work correctly when restarted, and then how to remove these errors altogether

[ INFO ] Generate self-signed SSL cert (4096 bits, expire in 10 years).
[ INFO ] Generate Diffie Hellman Group with openssl, please wait.
[ INFO ] Create required system accounts.
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p/o/s/postmaster/Maildir/new': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p/o/s/postmaster/Maildir': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p/o/s/postmaster': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p/o/s': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p/o': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net/p': Permission denied
chown: changing ownership of '/mnt/storage/vmail1/email.test.net': Permission denied
chown: changing ownership of '/mnt/storage/vmail1': Permission denied
chown: changing ownership of '/mnt/storage/public': Permission denied
chown: changing ownership of '/mnt/storage/sieve': Permission denied
chown: changing ownership of '/mnt/storage/backup': Permission denied
[ INFO ] Configure MariaDB database server.
[ INFO ] Setup daily cron job to backup SQL databases with /mnt/storage/backup/backup_mysql.sh
chown: changing ownership of '/mnt/storage/backup/backup_mysql.sh': Permission denied
[ INFO ] Configure Postfix (MTA).
[ INFO ] Configure Dovecot (POP3/IMAP/Managesieve/LMTP/LDA).
chown: changing ownership of '/mnt/storage/sieve/dovecot.sieve': Permission denied
[ INFO ] Configure Nginx web server.
[ INFO ] Configure PHP.
[ INFO ] Configure mlmmj (mailing list manager).
chown: changing ownership of '/mnt/storage/mlmmj': Permission denied
chown: changing ownership of '/mnt/storage/mlmmj-archive': Permission denied
[ INFO ] Configure ClamAV (anti-virus toolkit).
[ INFO ] Configure Amavisd-new (interface between MTA and content checkers).
[ INFO ] Configure SpamAssassin (content-based spam filter).
[ INFO ] Configure iRedAPD (postfix policy daemon).
[ INFO ] Configure iRedAdmin (official web-based admin panel).
[ INFO ] Configure Roundcube webmail.
[ INFO ] Configure SOGo Groupware (Webmail, Calendar, Address Book, ActiveSync).
[ INFO ] Configure Fail2ban (authentication failure monitor).

6 (edited by redmuser 2023-11-27 07:28:54)

Re: Storing iRedMail files (/var/vmail) on a network drive

OK, i will call it a success at least as far as installation process is concerned. No more errors it seems. The tricks seems to be to enable the root access on the NFS share. Without it, permission changes are not allowed for some reason

[ INFO ] Generate self-signed SSL cert (4096 bits, expire in 10 years).
[ INFO ] Generate Diffie Hellman Group with openssl, please wait.
[ INFO ] Create required system accounts.
[ INFO ] Configure MariaDB database server.
[ INFO ] Setup daily cron job to backup SQL databases with /mnt/storage/backup/backup_mysql.sh
[ INFO ] Configure Postfix (MTA).
[ INFO ] Configure Dovecot (POP3/IMAP/Managesieve/LMTP/LDA).
[ INFO ] Configure Nginx web server.
[ INFO ] Configure PHP.
[ INFO ] Configure mlmmj (mailing list manager).
[ INFO ] Configure ClamAV (anti-virus toolkit).
[ INFO ] Configure Amavisd-new (interface between MTA and content checkers).
[ INFO ] Configure SpamAssassin (content-based spam filter).
[ INFO ] Configure iRedAPD (postfix policy daemon).
[ INFO ] Configure iRedAdmin (official web-based admin panel).
[ INFO ] Configure Roundcube webmail.
[ INFO ] Configure SOGo Groupware (Webmail, Calendar, Address Book, ActiveSync).
[ INFO ] Configure Fail2ban (authentication failure monitor).
[ INFO ] Configure netdata (system and application monitor)

Now, when accessing the GUI, i still have no access to individual mail folders for some reason and I am greeted by the "Server Error: STATUS: Internal error occurred. Refer to server logs for more information" or "Server Error: LIST: Internal error occurred. Refer to server logs for more information" but what logs it would be, is a mystery.

File permissions look correct to me now, just FYI

root@email:/mnt/storage# ls -lah
total 7.5K
drwx------ 2 nobody nogroup   64 Nov 26 21:52 .
drwxr-xr-x 3 root   root    4.0K Nov 26 23:10 ..
drwx------ 2 root   root      64 Nov 26 23:22 backup
drwx------ 2 mlmmj  mlmmj     64 Nov 26 23:21 mlmmj
drwx------ 2 mlmmj  mlmmj     64 Nov 26 23:22 mlmmj-archive
drwx------ 2 vmail  vmail     64 Nov 26 23:21 public
drwx------ 2 vmail  vmail     64 Nov 26 23:22 sieve
drwx------ 2 vmail  vmail     64 Nov 26 23:21 vmail1

Not sure what the issue with the folder access is right now, but some additional set of eyes would be certainly welcome here. I think I solved the problem of installing on a shared network folder at least

7

Re: Storing iRedMail files (/var/vmail) on a network drive

Next step down. It turns out that the /mnt/storage where I installed my files did not have proper permissions. 777 did a trick for now.

Next problem is apparently in journalctl output - the scripts do not seem like to run over NFS protocol for some reason. I cannot find these error logs anywhere, really. Seems like I might be stuck at this step.

Nov 26 23:33:28 email php-fpm[720]: [WARNING] [pool inet] child 3038, script '/opt/www/roundcubemail/index.php' (request: "GET /mail/index.php?_task=mail&_action=getunread&_page=1&_remote=1&_unlock=0&_=1701041596616") executing too slow (10.400256 sec), logging
Nov 26 23:33:28 email php-fpm[720]: [WARNING] [pool inet] child 2688, script '/opt/www/roundcubemail/index.php' (request: "GET /mail/index.php?_task=mail&_action=list&_refresh=1&_layout=widescreen&_mbox=INBOX&_page=&_remote=1&_unlock=loading1701041596950&_=1701041596615") executing too slow (10.402504 sec), logging
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] child 3038 stopped for tracing
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] about to trace 3038
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] finished trace of 3038
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] child 2688 stopped for tracing
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] about to trace 2688
Nov 26 23:33:28 email php-fpm[720]: [NOTICE] finished trace of 2688

8

Re: Storing iRedMail files (/var/vmail) on a network drive

NFS is known to work fine with Dovecot (and iRedMail).

9

Re: Storing iRedMail files (/var/vmail) on a network drive

Thanks. I am coming up empty on examples, though, and no matter what permissions I assign to the root folder, I am still coming up with the "executing too slow" errors in the logs. Since elements are on high capacity LAN, I am not sure what else I can do to help bypass this problem.
Any references to NFS setup to be compatible with iRedMail?

10 (edited by redmuser 2023-11-30 09:31:11)

Re: Storing iRedMail files (/var/vmail) on a network drive

All righty, so reading in between the lines on a handful of posts I found, I added the following parameters to dovecot.conf file, per https://doc.dovecot.org/configuration_manual/nfs/ and updated the fstab per the same guidelines. I am not running a cluster, so I figure the guidelines for cluster deployment do not apply to me

# NFS optimizations
mmap_disable = yes
mail_fsync = always
mail_nfs_index = no
mail_nfs_storage = no

#fstab options
actimeo=60,nordirplus,noatime 

and now what I am getting is the following error

Nov 30 01:14:54 email dovecot[912]: imap(postmaster@email.test.net)<3262><N+saYVQLwpd/AAAB>: Error: Couldn't create mailbox list lock /mnt/storage/vmail1/email.test.net/p/o/s/postmaster//Maildir/mailboxes.lock: file_create_locked(/mnt/storage/vmail1/email.test.net/p/o/s/postmaster//Maildir/mailboxes.lock) failed: link(/mnt/storage/vmail1/email.test.net/p/o/s/postmaster//Maildir/mailboxes.locke3564a3861afc7ab, /mnt/storage/vmail1/email.test.net/p/o/s/postmaster//Maildir/mailboxes.lock) failed: Unknown error 524
Nov 30 01:14:54 email dovecot[912]: imap(postmaster@email.test.net)<3262><N+saYVQLwpd/AAAB>: Error: Mailbox Trash: Failed to autocreate mailbox: Internal error occurred. Refer to server log for more information. [2023-11-30 01:14:54]

which sends me to an undefined server log for more details. Well guess what, there are no more details to be had. I checked and re-checked permissions and they match local installation on a non-NFS mount point all the way down. Any pointers to help move it along?

I found this old bug (https://bugs.gentoo.org/654544) but it shows against 2.3.1 version, I am on 2.3.16 and it is also unconfirmed.

11

Re: Storing iRedMail files (/var/vmail) on a network drive

So just to cap it all off ... the problem is on the side of Windows Server and their NFS implementation it seems. I tried multiple NFS versions, permission combinations, etc. with the same net effect - it does not work with iRedMail (dovecot, specifically). When switching to NFS hosted on any Linux-based system, it all works really well and with no additional hiccups.