Mounting remote cifs share with autofs

Post your tutorials and howtos here.
User avatar
Arjen Balfoort
Site Admin
Posts: 9280
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Mounting remote cifs share with autofs

Postby Arjen Balfoort » 08 Aug 2014 14:35

When you want to mount a remote fs, and your system is using a wireless connection. You probably found out that the shutdown process hangs because the network has already been brought down while trying to unmount the remote fs. If that happens, you can use autofs to create the mount.

Make sure you have the share commented out in /etc/fstab, or disabled in systemd if you followed the toturial "Mount a remote share at boot with systemd". Don't forget to umount that share.

Explanation of the place holders:
  • [remote]: network path to the server. E.g.: //192.168.1.1
  • [share]: Share name on the server.
  • [myuser]: user to own the mount.
  • [mygroup]: group to use the mount.
  • [mountuser]/[mountuserpwd]: user credentials used to mount the remote share.
Open a terminal, and install autofs

Code: Select all

su
apt-get install autofs
mkdir -p -m755 /etc/auto.master.d
Create the autofs files

Code: Select all

echo "/media /etc/auto.master.d/auto.cifs.[share] --timeout=60 --ghost" > /etc/auto.master.d/cifs.autofs
echo "[share]    -fstype=cifs,credentials=/root/.media-[share].credentials,rw,iocharset=utf8,uid=[myuser],gid=[mygroup],_netdev    ://[remote]/[share]" > /etc/auto.master.d/auto.cifs.[share]
Create the credentials file

Code: Select all

echo "username=[mountuser]" > /root/.media-[share].credentials
echo "password=[mountuserpwd]" > /root/.media-[share].credentials
chmod 640 /root/.media-[share].credentials
Restart autofs

Code: Select all

service autofs restart
You now should be able to see your new mount in /media/[share]


SolydXK needs you!
Development | Testing | Translations

User avatar
amnesix
Posts: 176
Joined: 09 Nov 2013 12:46
Location: Berlin
Contact:

Re: Mounting remote cifs share with autofs

Postby amnesix » 10 Apr 2015 11:17

Thank you ! :)


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest