Howto : move the mail directory from /var/mail to /home/mail

here is a little howto about moving the mail directory on yunohost
my root partition was full while my /home partition had plenty of room, so i wanted to move the bigest folder from / : /var/mail to /home

first of all make your updates
apt-get update apt-get dist-upgrade

stop dovecot
service dovecot stop

copy the /var/mail directory with
rsync -ogpXEtlr --specials /var/mail /home

edit a new config file maillocation.conf in /etc/dovecot/yunohost.d/post-ext.d/ with
mail_home = /home/mail/%n mail_location = maildir:/home/mail/%n plugin { sieve = /home/mail/sievescript/%n/.dovecot.sieve sieve_dir = /home/mail/sievescript/%n/scripts/ }

restart dovecot
service dovecot start

check if dovecot is running well with
service dovecot status
and by checking logs in /var/log/mail.err

check if your conf is overwrited with
doveconf -n

when you are sure that every thing is working well you can delete the /var/mail directory

1 Like

Note that this folder is only available from Yunohost 2.5.4 (See [enh] Dovecot extensible configuration by julienmalik · Pull Request #175 · YunoHost/yunohost · GitHub)

yes it was not there when i started to play with conf files, it poped-up after the upgrade

Hi Bachy !

Let me advise against what you are proposing here.

With this change, you are forced to hand-modify the dovecot configuration file. This means that later update of this configuration file by yunohost will not be installed, or that if you install them (using yunohost service regenconf --force option) you will lose access to your mails.

IMHO a better option would have been to simply make a symbolic link from /home/mail to /var/mail, or use a bind mount. This would leave the dovecot conf untouched, while storing your mails on your biggest partition.

Hi juju,

i thought that the yunohost.d directory was here to provide the posibility of overwriting the dovecot conf without messing with updates …
If not, what is the purpose of yunohost.d/ ?
actually i started by editing the dovecot.conf file, and then when i upgraded, the dovecot conf upgrade messed, so i moved my changes in yunohost.d directory …
Do you mean that yunohsot service regenconf --force will delete my yunohost.d/mailocation.conf file ?