Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I've been Googling for a while now and I haven't found the answer to this yet, so I was hoping the good folks at LQ could lend a hand. I'm working on mounting shares from a W2K3 server on my FC3 workstation. I can mount the shares with no problem by executing:
mount -t cifs //servername/sharename /mnt/windows -o user=username,password=pwd
from a terminal as root. I put the same line in my /etc/fstab file to execute at bootup, but I get a message saying "line number x is bad in /etc/fstab". I'm assuming that this is because the command must be run as root, which it is not doing at boot up. My questions are these:
1. How can I make the above command run as root at bootup in my /etc/fstab?
2. I want to take my UN and PWD out of the command and use a credentials file. I created a file, /etc/credentials, with the syntax of:
username=un
password=pwd
I tried executing:
mount -t cifs //servername/sharename /mnt/windows -o credentials=/etc/credentials
from a terminal as root, but my syntax is off somewhere, and the man pages weren't much help to me. Once I can get the command to run as root at bootup, what should the proper syntax be to use the command with a credentials file? Thanks in advance.
Thanks for the reply cylix. I started out trying to use SMBFS, but there is apparently a problem between it and W2K3 shares. Whenever I try to mount the shares using SMBFS, I get the following:
cli_negprot: SMB signing is mandatory and we have disabled it.
17906: protocol negotiation failed
SMB connection failed
I have added "client signing=yes" to my globals in my smb.conf file, but that doesn't fix the problem. After a long conversation with Google, it told me to use cifs. This would be perfect if I could just figure out how to make it run as root at bootup in my /etc/fstab. Anyone got any ideas?
Must have misread that... don't worry... I'm going to correct my mistake or at least try..
If you are getting an error message in your logs about needing root access to mount.
chmod +s /path/to/mount.cifs
If you had to put in your own mount.cifs utility you probably want to make sure it's in the executable path or just along side the mount utility. Mount will call the mount.whatever and it doesn't need compiled against it. (checked just to be sure)
So your fstab line should look like this... I use vi so no newline spill over occurs. *fstab varies a bit from the mount stuff... so you need to make sure you make it all happy.
I ran "chmod +s /sbin/mount.cifs" on my system. I got the following syntax to work from a terminal as root:
mount -t cifs //server/share /mnt/windows -o credentials=/etc/credentials
I also made /etc/credentials readable only by root, chmod 700 /etc/credentials, as root. During bootup, i'm still getting the error message "line 9 in /etc/fstab is bad", ditto for the other 3 mount commands in my fstab file. Is there not a way to make fstab execute as root at startup, or is that not even my problem? Is there another startup file, .bashrc maybe???, that i can add the commands to that will execute properly?
It's not a root related issue (I don't know why mount wouldn't be running as root, but I thought to use that just in case)
If you fire up vi /etc/fstab it should highlight elements not syntactly correct. (at least if you have ansi color on and it's really vim and not that aged vi)
The only difference between here and my fstab, all spaces are tabs except when I get to 0 0, but any whitespace should be fine. Also, make sure the target directory exists.
+S is the setuid bit, so when the binary is executed it is ran as the owner of the file. (in this case we did setuid on both owner and group, which was a little overboard) Just make sure mount.cifs is owned by root and if that is still a worry, you could always do the same for mount (just for testing now)
But the error you are describing I reproduced quite well on my first stab entries. It's a syntax error purely.
Additionally, you don't have to reboot.
Just issue a mount -a
This will mount all things listed in the fstab file.
Many thanks cylix, that did the trick . One question though ...I was always able to succesfully execute:
mount -t cifs //server/share /mnt/windows -o credentials=/etc/credentials
from the terminal. Is there a specific reason that the same syntax wouldn't work from fstab, possibly that fstab just has to have that certain syntax? Either way, thanks again...
when called by sysinit, mount -a and a few other options are all that are called.
Simply, when mount was written, the code that parses the /etc/fstab file is different. Certain things are implicit *like not needing to mention mount* and all the options are parsed by column. (or really white space)
So there are literally two different sections of code for applying options. One section deals with information coming in as arguements on the command line and another section is called when the -a option is provided.
so when parsing options by file, you can save a great deal of time to simply knowing knowing where your data is going to be. Additionally, mount isn't the only tool which uses the fstab file. Utilities to dump the file system to archive also reference the fstab file. ala 0 0 (which are actually directives for the dump utility and any one else who cares to use them).
This is advantageous because you can now store meta parameters for other applications in a bit of a central location.
There are other applications for this as well, but I think this covers the basics.
I had to write a utility that accepted input from standard in, arguements and a configuration file. Trust me, I saved time wherever I could.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.