LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2020, 03:57 PM   #1
lindzay
LQ Newbie
 
Registered: Jun 2019
Location: Langley, BC, Canada
Distribution: Mint 19.3
Posts: 12

Rep: Reputation: Disabled
Question mount.cifs and /etc/fstab is convoluted. Can I simplify this?


mount.cifs and /etc/fstab is convoluted. Can I simplify this?


Anyone know a way around the mount.cifs needing an entry in /etc/fstab for every remote maybe wanted just so so the local mount-point is identified?

I am using Linux Mint 19.3 ... I read mount.cifs works differently than some other distributions.

I have a remote server farm and want to connect my /home/../DOWNLOAD to one of these remote disks - just one of many.

If my /etc/fstab has an entry
//192.168.1.150/u41disk/DOWNLOAD.41 /home/lindzay/XConnect/DOWNLOAD cifs credentials=/home/lindzay/XConnect/credentials,noauto,rw,users 0 0
Then I can successfully do
mount.cifs -o credentials=/home/lindzay/XConnect/credentials \
//192.168.1.150/u41disk/DOWNLOAD.41 \
/home/lindzay/XConnect/DOWNLOAD
...
umount /home/lindzay/XConnect/DOWNLOAD
NOTES:
  • The mount.cifs MUST use -o otherwise the mount will be done; but NO FILES are displayed or accessable
  • The ../credentials file MUST be named in both the /etc/fstab file AND the mount.cifs command.
  • The /etc/fstab items cannot (understandably) use $HOME; however the mount.cifs can use $HOME
  • I have a bash script to select the wanted remote (EG: 41) and am willing to include the sudo password in the script.
  • I successfully used sshfs - but I am after WiFi speed, not security encryption.
  • I tried sudo -S <<<password mount.cifs ... but that's still a user-mount which need the /etc/fstab entry.
I don't mind naming each user in each pc's fstab; but each user + all remote directories is expanding and complicating.
 
Old 04-26-2020, 06:05 PM   #2
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,177

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
Can you replace the user name with just the variable $USER, that should make it easier.
 
Old 04-26-2020, 06:15 PM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,678

Rep: Reputation: Disabled
You certainly have heard about AutoFS, haven't you?
 
Old 04-26-2020, 07:50 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
For regular users to mount a filesystem it has to be in fstab.

From the Mint file browser you should be able to create bookmarks and be able to permanently save passwords. If you need to access the shares from the command line that is a bit more complicated. This is a totally separate process from mount and /etc/fstab.

The option noauto means the share is not automatically mounted at boot time. This is required sometimes because the initialization process calls the mount process via fstab before the network is up and cifs remote shares fail to mount. However, systemd has fixed the problem so using the _netdev option will delay mounting although I have not tried it.
https://wiki.archlinux.org/index.php/Samba

The users option allows any regular user to mount and unmount those shares without using sudo.

Using mount.cifs is not necessary and you should use mount instead. Actually the mount command calls mount.cifs and while mount.cifs requires root privileges mount does not. Since the share is in the /etc/fstab all that is necessary to mount is the command
Code:
mount /home/lindzay/XConnect/DOWNLOAD
With autofs or x-systemd.automount when the user enters the share mount point directory, it is automatically mounted. It is automatically unmounted if not busy after an idle timeout has been exceeded.

Last edited by michaelk; 04-26-2020 at 07:51 PM.
 
Old 04-26-2020, 08:37 PM   #5
lindzay
LQ Newbie
 
Registered: Jun 2019
Location: Langley, BC, Canada
Distribution: Mint 19.3
Posts: 12

Original Poster
Rep: Reputation: Disabled
uteck
Yes I do use $USER in the script - but it won't work in the fstsb.


Shruggy

AutoFS .... I'm trying to not install anything new. My earlier reading was that it did a permanent mount same as fstab would do.

Besides, they don't go into the /mountpoint until the downloads are finished; and then do clerical things like rename files to a standard and move the files to another directory on the same disk. No copying, just download - rename - move

michaelk

I'm trying to auto-mount during logon; but only one of something like 10+ disks. That //192.168.1.150/u41disk/DOWNLOAD.41 could be any one in the server farm - which one is set by a bash command parameter. And stays until the user changes the parameter, like from 41 to 10 //192.168.1.150/u10disk/DOWNLOAD.10
 
Old 04-26-2020, 09:03 PM   #6
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,177

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
You should be able to have the script run automatically when a user logs in, so you don't need to mount with fstab.
I did something like that years ago to mount users on Ubuntu to their Windows share and have it show up on their desktop. I think did something with libpam_mount like in this link, https://wiki.ubuntu.com/MountWindowsSharesPermanently
But I was also using AD credentials to login to to Ubuntu desktop.

I just noticed some other options further down the page you may want to look at. The mount after login option may be easier as you could just call the script you have already.

Last edited by uteck; 04-26-2020 at 09:10 PM. Reason: found more stuff
 
Old 04-26-2020, 09:18 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
If you want to mount a share on a per user mount point then fstab will not work as far as I know. You could give users sudo rights to the mount command without requiring a password. I think this will work.

Quote:
ALL=(ALL) NOPASSWD: /bin/mount, /bin/umount
The advantage of using sshfs is it is "fully" script-able on a per user basis. Using keys and a config file will take some time to setup but then easy to expand if done right.

Last edited by michaelk; 04-26-2020 at 09:29 PM.
 
Old 04-28-2020, 06:15 PM   #8
lindzay
LQ Newbie
 
Registered: Jun 2019
Location: Langley, BC, Canada
Distribution: Mint 19.3
Posts: 12

Original Poster
Rep: Reputation: Disabled
[SOLVED] You can't! :banghead:

uteck

Thanks - Me Too! And it was only about a year ago. I lost exactly how because I switched to Green-Shoes-Ruby for it's sweet user interaction. But I remember I did have a no-problems bash script.

Looks to me that now mount:cifs allows no user connection without the /etc/fstab. This is a security good thing! But I also came across a reference that the /etc/fstab would accept a entry like

USER=lindzay /home/lindzay/DOWNLOAD


which is exactly what I'd want. But this isn't in the man fstab and I assume is for the future - the entry is just ignored.

michaelk

mount does NOT allow a user-mount in no way! I tried sudo. su, sudo-users, etc. and they all kick it back saying the mountpoint in not in fstab

I'm marking this [SOLVED] You can't! ... and am using sshfs

Thanks to all!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
manual mount cifs works but srcipt mount cifs has mount error (13): Permission denied CADIT Linux - Newbie 6 11-20-2009 02:48 PM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 06:15 AM
"Simplify! Simplify!" BillRice Linux - General 6 03-15-2002 01:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration