Bind Mount Directories

Bind-mounts are more robust than symlinks, especially when dealing with directories on removable storage: they use time-tested failsafe mounting techniques. Bind-mounted directories can also provide special permissions to users that differ from the source directory.

For example, let's say that you want to link a folder on the external USB hard drive to vsftpd's /var/ftp/pub folder.

  1. First, create the source folder on the external hard drive:

    sudo mkdir /media/usbdisk/ftp
  2. Next, (if necessary), create the destination folder on the system:

    sudo mkdir /var/ftp/pub
  3. After that, (if necessary) give the target user permissions over this specific directory. In this example, the target user is ftp, in group ftp. If you don't need to run programs from this folder, use 644. If you do, use 755.

    sudo chown ftp:ftp /media/usbdisk
    sudo chmod 644 /media/usbdisk
  4. Finally, add this bind mount entry to the /etc/fstab, so it will be mounted on boot every time.

    /media/usbdisk/ftp           /var/ftp/pub                 none    bind    0 0