Can I mount a disk to a domain?

I setup my Mailinabox in VPS.
Can I buy a storage disk and mount on one domain?

I will assume this is for email and web storage?

These steps have not been test but with some slight modification should work. Note though that some stuff wont be moved (Like SSL cert, and nginx settings files, etc)

NOTE: This is a HUGE unsupported modification, untested, never used elsewhere (AFAIK) Please BACKUP BEFORE DOING ANYTHING! I AM NOT RESPONSIBLE FOR LOST DATA.

1. Mount the external disk according to your VPS providers instructions (And make sure it auto-mounts on reboots!)
2. Do something like the following (be sure to change paths etc to match your server!)
    
    ## Avoid sudo here, just for simplicity login as root
    ## Stop system services so we do not crash anything
    systemctl stop mailinabox && systemctl stop dovecot && systemctl stop postfix && systemctl stop nginx

    ## Make folders on the external disk for the domain, not we are only moving www, mail, and cloud!
    mkdir -p /mnt/disk1/example.com/www
    mkdir -p /mnt/disk1/example.com/mail
    mkdir -p /mnt/disk1/example.com/cloud
    
    ## Move data over to the external disk (Be mindful of where slashes are placed! Format as I did!)
    mv /home/user-data/mail/example.com /mnt/disk1/example.com/mail/
    mv /home/user-data/www/example.com /mnt/disk1/example.com/www/
    
    ## Cloud data is trickier. Move each user one at a time: (Be mindful of where slashes are placed! Format as I did!)
    mv /home/user-data/cloud/user1@example.com /mnt/disk1/example.com/cloud/
    mv /home/user-data/cloud/user2@example.com /mnt/disk1/example.com/cloud/
    
    ## Now we symlink back to the original spot (Again, watch your slashes!)
    ln -s /mnt/disk1/example.com/mail/example.com /home/user-data/mail/example.com
    ln -s /mnt/disk1/example.com/www/example.com /home/user-data/www/example.com
    
    ## Same for each user: (Again, watch your slashes!)
    ln -s /mnt/disk1/example.com/cloud/user1@example.com /home/user-data/cloud/user1@example.com
    ln -s /mnt/disk1/example.com/cloud/user2@example.com /home/user-data/cloud/user2@example.com
    
    ## Reboot when done
    reboot

In theory, this should work as expected, but please test and make sure you change the commands to fit your domain, server, etc.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.