Well got myself a nice shiny VPS from Rackburst and currently in the process of setting it up to run my websites.
As part of the VPS package you get additional remote storage which is setup via SSHFS, which is great as the data stored there doesn’t get deleted if you re-built your VPS however the downside to this is when you restart your server the storage isn’t re-mounted on boot given you need to provide your SSHFS account password.
After a quick search on my friend Google found a very useful post over on Dark Launch on a script to use at boot.
This is the full process I followed including adding the script for it to run at boot:
You will need to install SSHFS and FUSE, on CentOS you need to enable the Epel repo instructions can be found here: http://www.centosblog.com/enable-epel-repo-on-centos-5-and-centos-6/
Initial command:
1 |
echo mypassword | sshfs myuser@ftp.mysite.com:/ ~/mounts/mysite -o workaround=rename -o password_stdin -o allow_other |
In the above command replace the following:
- mypassword – password for your SSHFS account
- myuser – username for your SSHFS server
- ftp.mysite.com – IP or hostname of you SSHFS fileserver
- ~/mounts/mysite – Folder to mount the filesystem to, this folder must exist before attempting to mount.
First your need to create the mount script and allow execution:
1 |
touch /opt/mount.sh && chmod +x /opt/mount.sh |
Next add the above command to the script file:
1 |
echo echo 6Htfh%24 | sshfs fsuser@1.1.1.1:/ /opt/storage -o workaround=rename -o password_stdin -o allow_other >> /opt/mount.sh |
Yes echo is there twice for a reason
We now need to add the script to the start up by doing the following:
1 |
echo sh /opt/mount.sh >> /etc/rc.local |
You can now test the script by either running it or restarting the server.
1 |
sudo ./mount.sh |
We can then check the filesystem is now mounted by running the following:
1 2 3 4 5 6 7 |
# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/simfs simfs 20G 1.5G 19G 8% / none devtmpfs 1.0G 4.0K 1.0G 1% /dev none tmpfs 1.0G 0 1.0G 0% /dev/shm fsuser@1.1.1.1:/storage fuse.sshfs 493G 90G 379G 20% /opt/storage |
Please note the process may vary on other Linux flavours.