On this page

  1. Links

Use mount --bind To Move The Website And Email Directory Of a ISPConfig 3 Server To a New Directory

In the following guide, I will explain the procedure on how to move the email and website directory of a ISPConfig 3 installation to a new partition. This might become handy when your current partition runs out of space. I will use a bind mount for this, a symlink will not work here as ISPConfig checks path for symlink attacks, so if the website or email path contains a symlink, ISPConfig will reject to write to that directory. In this example, I will move the www and email directory to the /home partition. You dont have to move both partitions together, so moving just the email or web partition will work as well.

Stop the email and web server

service postfix stop
service dovecot stop

When you use apache, use:

service apache2 stop

For nginx server, use:

service nginx stop

Move the email directory to the /home partition

mv /var/vmail /home/

and create a new mount point with correct permissions

mkdir /var/vmail
chown vmail:vmail /var/vmail

Move the www directory to the /home partition

chattr -i /var/www/clients/client*/web*
umount /var/www/clients/client*/web*/log
mv /var/www /home/

and create a new mountpont

mkdir /var/www

Now edit the /etc/fstab file to add the 2 bind mounts

vi /etc/fstab

add the following 2 lines right after the lines for your harddisk partitions

/home/vmail /var/vmail none bind,nobootwait,_netdev 0 0
/home/www /var/www none bind,nobootwait,_netdev 0 0

apply the new mount configuration

mount -a

and start the services

service postfix start
service dovecot start

for apache servers:

service apache2 start

for nginx servers use:

service nginx start

 

Till Brehm

About Till Brehm

Over 20 years experience as Software Developer and Linux System Administrator. Till Brehm is the founder and lead developer of the ISPConfig Hosting Control Panel software (since 2000) and he founded HowtoForge in 2005 as a place to share Linux knowledge with other Linux enthusiasts.

Share this page:

Suggested articles

6 Comment(s)

Add comment

Comments

By: js

Where en how do I edit  /etc/fstab to make this ("remount-ro,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0") back working?

# /etc/fstab: static file system information.

# Use 'blkid' to print the universally unique identifier for a

# device; this may be used with UUID= as a more robust way to name devices

# that works even if disks are added and removed. See fstab(5).

# <file system> <mount point>   <type>  <options>       <dump>  <pass>

proc            /proc           proc    defaults        0       0

# / was on /dev/vda1 during installation

UUID=ce8a4f13-1cd5-4f40-95ad-19522d5a5d82 /               ext3    errors=remount-ro,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0       1

UUID=992212e3-4582-459c-944b-48f05476cae7 /data-disk ext4 errors=remount-ro 0 0

/data-disk/www /var/www none bind,nobootwait,_netdev 0 0

/data-disk/vmail /var/vmail none bind,nobootwait,_netdev 0 0

Thx

 

By: babydunk

hello

i would like to move the /var/backup dir because my backups are taking up far to much space for the root partition

 

would this be the right way to do that

mv /var/backup /home

mkdir /var/backup

nano /etc/fstab

add

/home/backup /var/backup none bind,nobootwait,_netdev 0 0

 

mount -a

 

service nginx start

 

thanks for you help in advance 

Chris

By: Jesse Norell

Moving mysql databases entails:

 

service mysql stop

mkdir /var/lib/mysql

chown --reference /home/mysql/ /var/lib/mysql/

chmod --reference /home/mysql/ /var/lib/mysql/

echo '/home/mysql /var/lib/mysql none bind,nobootwait,_netdev 0 0' >> /etc/fstab

mount -a

service mysql start

By: Jesse Norell

Moving mysql databases entails:

 

service mysql stop

mv /var/lib/mysql /home/

mkdir /var/lib/mysql

chown --reference /home/mysql/ /var/lib/mysql/

chmod --reference /home/mysql/ /var/lib/mysql/

echo '/home/mysql /var/lib/mysql none bind,nobootwait,_netdev 0 0' >> /etc/fstab

mount -a

service mysql start

By: Michael

When I did this, I now have a COPY of the /var/www directory in the /home/directory?  Even new sites that I create (did not exist before I did this) are being duplicated in the /var/ directory.  I was expecting it to MOVE the data and any new site would be created in the /home/ directory instead of the /var/ ... what did I do wrong or am I not understanding what this does?

By: till

When you followed this guide, then you moved the data from /var to /home, then you created a BIND mount which ensures that the /home directory is used. Check usage with 'df -h' command, you will see that space in /var has been freed and space in /home is used now. Of course, the file still show up in /var, that's the purpose of a bind mount, but they don't use any space.