This guide shows how to mount FTP servers as local directories in Linux using rclone, with automatic mounting at system startup.
Install rclone
sudo apt install rclone # Debian/Ubuntu
sudo dnf install rclone # Fedora
Configure rclone
Create a new remote configuration:
rclone config
Example configuration for an FTP server:
n) New remote
name> my-ftp
Storage> ftp
host> ftp.example.com
user> [email protected]
pass> *** ENCRYPTED ***
explicit_tls> true
no_check_certificate> true
The configuration is saved to ~/.config/rclone/rclone.conf
.
Create a mount script
Create a file named mount-ftp.sh
:
#!/bin/bash
# Configuration
REMOTE_NAME="my-ftp"
MOUNT_POINT="$HOME/my-ftp"
LOG_FILE="$HOME/.rclone-my-ftp.log"
# Ensure mount point exists
mkdir -p "$MOUNT_POINT"
# Function to check if mount is already active
is_mounted() {
mount | grep -q "$MOUNT_POINT"
return $?
}
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
}
# Check if already mounted
if is_mounted; then
log_message "$REMOTE_NAME is already mounted at $MOUNT_POINT"
exit 0
fi
# Check network connectivity
if ! ping -c 1 -W 5 8.8.8.8 > /dev/null 2>&1; then
log_message "ERROR: Network is not available. Aborting mount."
exit 1
fi
# Mount the FTP server
log_message "Mounting $REMOTE_NAME FTP server to $MOUNT_POINT..."
rclone mount $REMOTE_NAME: "$MOUNT_POINT" \
--daemon \
--vfs-cache-mode full \
--buffer-size 32M \
--transfers 4 \
--ftp-concurrency 4 \
--log-file "$LOG_FILE"
# Check if mount was successful
sleep 2
if is_mounted; then
log_message "Successfully mounted $REMOTE_NAME FTP server to $MOUNT_POINT"
exit 0
else
log_message "ERROR: Failed to mount $REMOTE_NAME FTP server"
exit 1
fi
Make the script executable:
chmod +x mount-ftp.sh
Set up automatic mounting at system startup
Add the script to crontab to run at system boot:
crontab -e
Add this line:
@reboot /home/username/mount-ftp.sh
Managing your FTP mounts
Mount manually:
./mount-ftp.sh
Unmount:
fusermount -u ~/my-ftp
Check mount status:
ls -la ~/my-ftp
Multiple FTP servers
For multiple FTP servers:
- Configure each server in rclone with a unique name
- Create a separate mount script for each server
- Add each script to crontab
Example for two servers:
# In ~/.config/rclone/rclone.conf
[server1]
type = ftp
host = ftp1.example.com
user = [email protected]
pass = *** ENCRYPTED ***
[server2]
type = ftp
host = ftp2.example.com
user = [email protected]
pass = *** ENCRYPTED ***
# In crontab
@reboot /home/username/mount-server1.sh
@reboot /home/username/mount-server2.sh
That's it! Your FTP servers will now mount as local directories at system startup.