5.3.13. Mount storage to VPS using CurlFtpFS

Using the method described in this article, you can mount not only storage but also any resource accessible via FTP to a VPS.

Storages can be connected to a VPS and used just like regular directories. Data is transferred between the VPS and the storage transparently to the user, as if the storage's contents were located in a directory on the server (albeit with slower access).

  1. Install CurlFtpFS on the server:
    apt install curlftpfs
    dnf install curlftpfs
    pacman -S curlftpfs
  2. Create a mount directory on the server (after mounting, the contents of the storage will be displayed there):
    mkdir /mnt/storage

    Note Instead of /mnt/storage, you can specify any directory on the server.

For one-time manual mounting (which is not preserved when the server is restarted), use the following command:

curlftpfs -o allow_other cdnXX:ftp-password@cdnXX.backup.ukraine.com.ua /mnt/storage

In command:

  • cdnXX and ftp-passwordlogin and password to access the storage via FTP.
  • cdnXX.backup.ukraine.com.ua — the FTP host address of your storage.
  • /mnt/storage — mounting directory (see above).

Instructions for configuring automatic mounting (settings are retained after the server is restarted):

  1. In the home directory of the user under which CurlFtpFS will be run, create a file named .netrc with the following contents:
    machine cdnXX.backup.ukraine.com.ua
    login cdnXX
    password ftp-password

    In the lines:

  2. Set the permissions for the created file to 600:
    chmod 600 /path/to/.netrc

    In the command: /path/to/.netrc — the path to the .netrc file you created.

  3. Add a line like this to the /etc/fstab file:
    curlftpfs#cdnXX.backup.ukraine.com.ua /mnt/storage fuse allow_other,uid=0,gid=0,_netdev 0 0

    In the line:

    • cdnXX.backup.ukraine.com.ua — the FTP host address of your storage.
    • /mnt/storage — mounting directory (see above).
  4. Apply the changes without restarting the server:
    mount -a

To disable automatic mounting, simply remove the added line from /etc/fstab.

To unmount, use the following command:

fusermount -u /mnt/storage

In the command: /mnt/storage — the mount point (see above).

Змест

    (2)