LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cifs not mounting on boot (https://www.linuxquestions.org/questions/linux-software-2/cifs-not-mounting-on-boot-731689/)

mitchell2345 06-09-2009 11:17 AM

cifs not mounting on boot
 
Hi,

I have a CentOS 5.3 server. I cannot get my cifs share to mount on boot. After the machine is up I can issue a mount /mnt/sql just fine. I tried putting that in rc.local and it still didnt work.

some details:
Code:

//10.0.0.7/share    /mnt/sql                cifs    username=mail,password=xxxxxxxx  0 0
Code:

[root@massmail ~]# chkconfig --list netfs
netfs          0:off  1:off  2:on    3:on    4:on    5:on    6:off

Code:

[root@massmail ~]# service netfs status
Configured CIFS mountpoints:
/mnt/sql
[root@massmail ~]#

Code:

[root@massmail ~]# ls /mnt/sql
[root@massmail ~]#

Code:

[root@massmail ~]# mount /mnt/sql
[root@massmail ~]# ls /mnt/sql 
news.txt  promos.txt  updates.txt  promos.txt  f.txt
connections.txt  iaap_surveys.txt  op.txt    surveys.txt

only error I can find is:
Code:

[root@massmail ~]# dmesg |grep CIFS
CIFS: Unknown mount option _netdev
 CIFS VFS: Error connecting to IPv4 socket. Aborting operation
 CIFS VFS: cifs_mount failed w/return code = -113
CIFS: Unknown mount option _netdev
 CIFS VFS: Error connecting to IPv4 socket. Aborting operation
 CIFS VFS: cifs_mount failed w/return code = -113

What is the deal? why wont it mount on boot? What does this error mean? My guess is maybe samba is trying to start before the network is up. How can i change the order?

Thanks,
Mitchell

David1357 06-09-2009 01:11 PM

Quote:

Originally Posted by mitchell2345 (Post 3568114)
My guess is maybe samba is trying to start before the network is up. How can i change the order?

Your guess is correct:
Code:

[user@machine:~]:./errcvt 113
Error 113 is No route to host

The first thing you want to do is to add the "noauto" option to the line in "/etc/fstab". That will prevent the boot time errors from occurring.

The easy way to get it to mount at boot is to add "mount /mnt/sql" to "/etc/rc.local".

The harder way to get it to mount at boot is to write your own custom init script that runs after networking. The proper way to write an init script varies from distro to distro. You can usually find enough examples in your "/etc/init.d" directory to figure out how to write your own.

mitchell2345 06-09-2009 01:25 PM

forgot to add this to the org. post.

i have tried the rc.local.

Code:

[rsmtech@massmail ~]$ cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
mount /mnt/sql

I added the noauto to the fstab and still no joy.

More suggestions?

Thanks,
Mitchell

David1357 06-09-2009 02:14 PM

Quote:

Originally Posted by mitchell2345 (Post 3568234)
More suggestions?

Add some debugging to your mount command.
Code:

mount /mnt/sql > /var/log/mntsql.log
You may need to specify the full path to mount (e.g. /bin/mount) because init does not usually have PATH set.

jschiwal 06-09-2009 02:22 PM

Firstly, don't have the password in /etc/fstab. Use cred= option instead and have it point to a credentials file that only the user can read. Anyone can read /etc/fstab, so the password isn't secret. What version of mount.cifs do you have? I use the _netdev option in /etc/fstab without getting an error.

I'm also not sure if a windows share would be the best for a database server to run on if that is what this share is for, rather than a share of where sql queries are stored. NFS would probably work better.

David1357 06-09-2009 07:29 PM

Quote:

Originally Posted by jschiwal (Post 3568289)
I use the _netdev option in /etc/fstab without getting an error.

That option is news to me. If it works, it is better than my suggestions.

mitchell2345 06-10-2009 08:44 AM

Quote:

Originally Posted by David1357 (Post 3568556)
That option is news to me. If it works, it is better than my suggestions.

when i put that in it ignores it. in the logs it says it doesnt know what it is.

Mitchell

David1357 06-10-2009 09:35 AM

Quote:

Originally Posted by mitchell2345 (Post 3569166)
when i put that in it ignores it. in the logs it says it doesn't know what it is.

What happened when you added debugging to your "mount" command in "rc.local"? Did you add the full path to "mount"?

mitchell2345 06-10-2009 11:30 AM

Quote:

Originally Posted by David1357 (Post 3569229)
What happened when you added debugging to your "mount" command in "rc.local"? Did you add the full path to "mount"?

[rsmtech@massmail ~]$ cat mount.log
mount error 113 = No route to host
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

how do i find what version of mount.cifs I have?

David1357 06-10-2009 01:40 PM

Quote:

Originally Posted by mitchell2345 (Post 3569368)
[rsmtech@massmail ~]$ cat mount.log
mount error 113 = No route to host

You are still trying to mount the share before the network connection is completely functional.

Is your network connection through a wireless interface? If so, you have to wait for the authentication to complete. Frequently with wireless connections, the computer can fully believe the "network" is up and running before the "connection" is completely up and running.

You might want to put something like this before the mount command:
Code:

while ! ping -c 1 10.0.0.7 ;
do
    sleep 1 ;
done
/bin/mount /mnt/sql

You might have to tweak the "ping" parameters to get the command right. I am writing this without testing it.

Quote:

Originally Posted by mitchell2345 (Post 3569368)
How do i find what version of mount.cifs I have?

Good question. My "mount.cifs" command prints this as part of the usage:
Code:

To display the version number of the mount helper:
        mount.cifs -V

However, running "mount.cifs -V" only causes the usage to be printed again.

mitchell2345 06-10-2009 02:47 PM

ill try adding the if statement. no its not on a wireless connection.

jschiwal 06-10-2009 03:24 PM

AFAIK, the _netdev fstab option entry allows the bootup scripts to use -o no_netdev to mount non-network filesystems before the network is ready, or the -o _netdev option in a mount command to mount entries with the _netdev option.

Check the manpage for the mount command and see if the _netdev option exists. It has been around for quit a while. I don't understand why you wouldn't have it.

A boot up script should be able to use the _netdev or no_netdev options to mount. This would enable you to mount network filesystems without needing to explicitly list them in the script. e.g. mount -a -o _netdev

mitchell2345 06-11-2009 04:56 PM

Quote:

Originally Posted by David1357 (Post 3569509)
You might want to put something like this before the mount command:
Code:

while ! ping -c 1 10.0.0.7 ;
do
    sleep 1 ;
done
/bin/mount /mnt/sql

You might have to tweak the "ping" parameters to get the command right.

YAY adding that if statement worked like a charm.

Thanks!
Mitchell

David1357 06-12-2009 09:51 AM

Quote:

Originally Posted by mitchell2345 (Post 3570988)
YAY adding that if statement worked like a charm.

I am glad it worked. You may want to put a counter in there to make sure that the while loop does not run forever (e.g. you are booting your machine while not connected to the network). Here is some sample script code:
Code:

#!/bin/bash
COUNTER=0
while true ;
do
    echo "COUNTER = ${COUNTER}"
    ((COUNTER++))
    if (( COUNTER >= 10 )) ; then
        echo "Counter limit reached.  Exiting..."
        exit 1 ;
    fi
done


pepsimachine15 06-12-2009 02:45 PM

if you want this to work from your fstab, try changing the 0 0 at the end to 0 1, like such:

Code:

//10.0.0.7/share    /mnt/sql                cifs    username=mail,password=xxxxxxxx  0 1
sometimes this will help, i believe the 1 at the end will tell fstab to retry the mount again later at the end of boot, possibly after your net starts.


All times are GMT -5. The time now is 08:54 PM.