Here’s how I modified Mthrboard’s guide to Auto-Mounting filesystems in Linux to work for Windows shares using SMB/CIFS. My numbering matches up with Mthrboard’s guide.
- First, make sure you can manually mount the Windows share and access them in Ubuntu. To get to that point, I used the first half of this guide https://linuxize.com/post/how-to-mount-cifs-windows-share-on-linux/ but stopped before the part about “Auto Mounting”. The only thing to change from that guide is what Mthrboard said: Make a new folder in
/mnt
calledsmb
, and mount your media directories in/mnt/smb
, so/mnt/smb/tv
,/mnt/smb/movies
, etc. Don’t place the folders directly in/mnt
.
Then install autofs, like in the Mthrboard guide
- When you edit the
auto.master
file, instead of
/mnt/nfs /etc/auto.nfsdb --timeout=0 --browse
use this as the last line instead:
/mnt/smb /etc/auto.cifs-shares --timeout=0 –browse
And then save the file.
Next, instead of creating a file
/etc/auto.nfsdb
create the file:
/etc/auto.cifs-shares
In that file, make a separate line for each of your shared media directories similar to the Mthrboard guide but remove timeo=100
and noatime
as they don’t exist in SMB, and change the format of your remote machine’s IP address:
films -fstype=cifs,ro,iocharset=utf8,credentials=/etc/win_cred,file_mode=0644,dir_mode=0755 ://192.168.1.201/Films
tv -fstype=cifs,rw,iocharset=utf8,credentials=/etc/win_cred,file_mode=0777,dir_mode=0777 ://192.168.1.201/TV
films
or tv
is the name of each of your linux media folders you created inside /mnt/smb
ro
should be rw
if you use plex DVR, and I had to change file_mode
and dir_mode
to 0777
.
The credentials
directory should be wherever your windows username and password are stored as in the link in step 0, which should probably stay at /etc/win_cred
The final IP address is the IP address of your remote Windows machine, and the windows shared folder name.
Add additional lines like in Mthrboard’s guide for every SMB folder you want auto-mounted, but make sure you remove timeo=100
and noatime
.
- Proceed with Mthrboard’s guide.
I pieced this together using this guide around the same time as this post was made.
Let me know if it helps! Reposting this because I accidentally deleted this post.