Autofs

From The World according to Vissie
Jump to navigation Jump to search

Setup [Debian]

Have a look at the creation of a aufo FS in this article, it works like a charm!

https://6ftdan.com/allyourdev/2018/02/04/proxmox-a-vm-server-for-your-home/
apt-get install sshfs fuse autofs

if arch

yay -S sshfs fuse autofs curlftpfs 

We will reference a location and a directory in the next 2 config files. In /etc/auto.master you will add the root location.

Add this line to the end of your Debian: /etc/auto.master , Arch: /etc/autofs/auto.master file:

/media/sshfs /etc/auto.sshfs --timeout=30,--ghost 

Be sure to leave a blank line after it.

And add the following line to /etc/auto.sshfs on Debian, /etc/autofs/auto.sshfs on Arch

backups -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536,IdentityFile=/home/user/.ssh/id_rsa :sshfs\#sshfs@192.168.1.10\:/mnt/raid/proxmox_backup

Be sure to leave a blank line after it. The first piece of the line needs to be the local backup directory. The last part :sshfs\#sshfs@192.168.1.10\:/mnt/raid/proxmox_backup is the sshfs instruction, remote username, the IP address of the “other computer”, and lastly the directory on the “other computer” to mount. The IdentityFile field is mandatory.

Then run:

/etc/init.d/autofs restart
ls /mnt/backups

Debugging auto mount issues

Try

sudo ssh -p 1234 -i /home/user/.ssh/id_rsa user@10.10.10.123

For better debugging you might try running automount in foreground.

systemctl stop autofs.service
sudo automount -f -v