only 5%

Become a Vendor

COMMISSION

Developer for

Siberian&Nwicode

Mount remote FTP server as folder on Linux and auto startup it

Sometimes we need to mount the FTP server as a folder on Linux and automatically mount it on reboot. We used this system on a client who needed to back up to an external server. This example is for CentOS 7.

# Installing the CurlFtpFS package (need EPEL repo):
yum install curlftpfs

A few CurlFtpFS command.

# $ftphost = The FTP host
# $mount = Mounted to folder
# $user = FTP username
# $pass = FTP password

# Mount the CurlFtpFS

curlftpfs $ftphost $mount -o user=$user:$pass,allow_other

# Unmount the CurlFtpFS

fusermount -u $mount

Auto mount CurlFtpFS

Creating the startup script:

vi /etc/init.d/mountftp

Copy and paste this. Change the FTP credentials and mounted to folder.

#!/bin/sh
#
# Run-level Startup script for curlftpfs
#
# chkconfig: 345 91 19
# description: Startup/Shutdown the curlftpfs

# FTP user, password, and host (you can specify the port also eg. ftp.example.com:2002)
ftpUser=user
ftpPass=password
ftpHost=ftp.example.com

# Mounted to folder
mPath=”/var/mounted/ftp”

# Create the mounted to dir if doesn’t exist
if [ ! -d $mPath ]; then
mkdir -p $mPath
fi

case “$1” in
start)
curlftpfs $ftpHost $mPath -o user=$ftpUser:$ftpPass,allow_other
;;
stop)
fusermount -u $mPath
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo “Usage: $0 start|stop|restart|reload”
exit 1
esac
exit 0

Make the startup script persistent across reboot.

# chkconfig mountftp on

Available command.

# Start
service mountftp start

# Restart and reload
service mountftp restart
service mountftp reload

# Stop
service mountftp stop

Leave a Reply

Your email address will not be published. Required fields are marked *

Appteam to offer you a better experience on this site uses its own and third-party technical, analytical and profiling cookies. The site also uses third-party tracking cookies to adapt advertising to your preferences.

If you want to know more or refuse consent to the use of cookies clicca qui. By continuing to browse, you consent to the use of cookies.

Privacy Settings saved!
GDPR Center

When you visit a website, it can store or retrieve information on your browser, mainly in the form of cookies. Check your personal cookie services here.

These cookies are necessary for the website to function and cannot be disabled in our systems.

In order to use this website we use the following technically required cookies
  • wordpress_logged_in_
  • wordpress_sec
  • wordpress_test_cookie
  • yuyujytujk
  • tyuikrtyk
  • ytuiktyuiktyuik

We use WooCommerce as a purchasing system. 2 cookies will be stored for the shopping cart and order processing. These cookies are strictly necessary and cannot be disabled.
  • woocommerce_cart_hash
  • woocommerce_items_in_cart

Decline all Services
Accept all Services

Main Menu

Need Help? Chat with us