[SOLVED] mount.cifs and /etc/fstab is convoluted. Can I simplify this?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
Distribution: Ubuntu based stuff for the most part
Posts: 1,177
Rep:
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
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.