Samba: On Demand CIFS Mounting of Shares

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Gotit

Re: Samba: On Demand CIFS Mounting of Shares

Post by Gotit »

Hi and thanks for the tutorial!
I have the mount on demand working like a charm, switching to "/media" instead of "/mnt" was the secret sauce for me. However, the FS doesn't umount with my user.
*** When you are done using it you can use the little mount icon next to the name to unmount it if there is one for your desktop or right click it to unmount it.
I have to use sudo it in the terminal to make umount successful. My user gets

Code: Select all

umount: /media/N-Media: umount failed: Operation not permitted.
The mount point folder is owned by root until I mount my desired FS and then ownership is given to me.
My fstab entry is:

Code: Select all

//192.168.1.1/netdrive/Media /media/N-Media cifs guest,vers=1.0,noauto,x-systemd.automount,x-systemd.idle-timeout=1min,_netdev,user,uid=1000,iocharset=utf8,sec=ntlm 0 0
I'm running with systemd hence the x-systemd options. I've tried without the timeout option too, but it makes no difference.
Right click > unmount in Thunar doesn't seem to work.
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Samba: On Demand CIFS Mounting of Shares

Post by altair4 »

My HowTo is not about a systemd style automount so none of these options x-systemd.automount,x-systemd.idle-timeout=1min would be applicable. The netdev option would also not be applicable although it probably will do no harm because the share is not being mounted at boot.

The reason you can't unmount it as a regular user is because systemd doesn't understand the concept of an old style AutoFS mount so it's mounting the share automatically despite the noauto and the only user present at boot is root..

This HowTO uses a different method to mount.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
cas1701

Re: Samba: On Demand CIFS Mounting of Shares

Post by cas1701 »

Altair,

I have to say thank you so much for your brilliant HowTo. I’m a recent arrival to the world of Linux and have a NAS, which I used easily and successfully in Windows 7. I spent much time trying to find out how to mount the shares from my NAS onto my new Linux installation and seemed to be frustrated at every turn.

Then I found this. Simplicity in itself, bravo sir.
antcj
Level 3
Level 3
Posts: 148
Joined: Thu Jun 28, 2012 11:17 pm

Re: Samba: On Demand CIFS Mounting of Shares

Post by antcj »

Altair thank you
I've seen your posts on this before and never got round to looking into it.
Usual story its working so why worry.
mistake, should have done it long ago.

Today i finally had a look
Im blown away. so easy (thanks to your instructions)
and speed...

My speeds to transfer a 4gb file to my NAS took 2 minutes, via smb
via cifs, 40secs
absolutely stoked
antcj
Level 3
Level 3
Posts: 148
Joined: Thu Jun 28, 2012 11:17 pm

Re: Samba: On Demand CIFS Mounting of Shares

Post by antcj »

Altair
using the cifs method you have posted, with systemd automount.

I have noticed that if the server is down then i no longer have access to local files on the pc.
I cant even open home folder.
i have seen this on 2 pc with mint20, after a clean install. I also noticed it on mint 19.3
Ive obviously missed something?
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Samba: On Demand CIFS Mounting of Shares

Post by altair4 »

This HowTo does not use a systemd automount. I do have another one where I do discuss it: viewtopic.php?f=42&t=326160
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
nigelk
Level 1
Level 1
Posts: 21
Joined: Thu Aug 27, 2015 6:57 pm
Location: UK
Contact:

Re: Samba: On Demand CIFS Mounting of Shares [SOLVED]

Post by nigelk »

Thanks, altair4, for this. It was (almost) exactly what I needed. Here's my experience of following it.

I finally got a hub from my ISP with a working USB port, and attached the SSD from my old laptop. I could get at it via the File/Connect to server... route in Nemo but wanted a less irritating method. Got my id, made sure cifs was up-to-date (it was), did sudo mkdir /media/NAS and I was ready for testing.

sudo mount -t cifs //vodafone.broadband/sabrent_1_d2c2 /media/NAS -o guest,uid=1000,vers=2.1

connected the share, and displayed the mount point on the desktop, in the file manager, and the removable icon applet on the panel. Since the hub generates a samba share, that gave me all the access I really need. Ready for automation via fstab! I put the following line in fstab:

//vodafone.broadband/sabrent_1_d2c2 /media/NAS cifs guest,noauto,user,uid=1000,vers=2.1 0 0

and rebooted. This is where things deviated a bit from my expectations:
In use this will be seamless:

*** When you need access to the share simply access the icon in the file manager or in your application and fstab will do the rest
*** When you are done using it you can use the little mount icon next to the name to unmount it if there is one for your desktop or right click it to unmount it.
but there was no desktop icon, nothing in the file manager, and no panel applet. Have I misunderstood something? I'm running Mint 20.1 Cinnamon, by the way. Perhaps something has changed since the tutorial was written?

I poked around a bit to see what had happened and found that if I clicked on the Computer icon on the desktop, the NAS folder was shown and the share was accessible (and the icons all appeared), so the fstab entry was doing something, just not generating the udisks response I expected to see after logging in. Further research showed me I could run

mount /media/NAS

and doing so also produced all the expected mount point icons. It looks like the mount point icons are generated only when the share is actually mounted.

As a work-around, I created a startup application to run that command. This may be useful for someone else with the same issue but I feel it rather defeats the object of 'On Demand CIFS Mounting of Shares'.

But, all-in-all, a very useful tutorial, even after almost 5 years. Thanks again!
Last edited by nigelk on Sun Mar 06, 2022 8:44 pm, edited 2 times in total.
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Samba: On Demand CIFS Mounting of Shares

Post by altair4 »

No longer use Mint so I fired up Mint Cinnamon in a VBox guest, created a mount point at /media/MPTest, then added the following to my fstab:

Code: Select all

//gort.local/public /media/MPTest cifs guest,noauto,user,uid=1000 0 0
It shows up on the side panel in Nemo ( As well as in things like Writer ):
Nemo-Media-Noauto-Mount.png
Nemo-Media-Noauto-Mount.png (4.34 KiB) Viewed 2092 times
When selected it will mount then display the contents of the share and change the panel icon to indicate that I can unmount it:
Nemo-Media-Noauto-Mount2.png
Nemo-Media-Noauto-Mount2.png (4.5 KiB) Viewed 2092 times
What it will not do is create a desktop icon. Hmm....

Tried it with Mint Mate then XFCE with the same results. Will work + display desktop icon on Xubuntu and other distros XFCE offerings - just not in Mint's XFCE.

Have no idea.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
nigelk
Level 1
Level 1
Posts: 21
Joined: Thu Aug 27, 2015 6:57 pm
Location: UK
Contact:

Re: Samba: On Demand CIFS Mounting of Shares

Post by nigelk »

altair4, you're a star! :D
altair4 wrote: Wed Apr 14, 2021 8:35 am It shows up on the side panel in Nemo ( As well as in things like Writer ):
I generally (i.e. unthinkingly and almost always) have nemo's sidebar in Treeview mode so I never saw the mount point under network in the Places sidebar. That's good enough for me, I can remove my start-up work-around now I know where to look.

As for the desktop icon, I guess Mint has changed behaviour from the version you were using when you wrote your tutorial. I can live without it. Perhaps it will find its way back into a later kernel...

Thanks again for the original tutorial, and a ***special thanks*** for going out of your way to check this out.

EDIT: Actually, I've just noticed that the desktop icon shows up when I click on the entry under 'Network'. All good.
Post Reply

Return to “Tutorials”