Announcement

Collapse
No announcement yet.

Mounting cifs share from /etc/fstab on boot

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Mounting cifs share from /etc/fstab on boot

    I have a Samba share listed in /etc/fstab as follows:
    Code:
    hpmediavault:FileShare /mediavault cifs user,users,atime,auto,rw,nodev,pass='' 0 0
    . It doesn't get mounted on bootup, but I'm able to mount it later on with the obvious mount /mediavault. What can I do to get it mounted automatically on bootup?

    #2
    Re: Mounting cifs share from /etc/fstab on boot

    try adding "_netdev" option

    from man mount:
    _netdev
    The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).

    Comment


      #3
      Re: Mounting cifs share from /etc/fstab on boot

      I am amazed it mounts at all. The hpmediavault:FileShare is not like any notation I have seen, which may just mean my smb knowledge is dated.

      I think that with options user and users it will not get mounted at boot as the user is unknown. If your purpose is to allow a user to read and write to it you should mount it on a mount point owned by that user and us the uid= gid= options.

      Comment


        #4
        Modified fstab but still no success

        Using the advice from this thread, I changed the fstab line to:
        Code:
        hpmediavault:FileShare /mediavault cifs defaults,guest,_netdev 0 0
        But I still don't get /mediavault mounted on bootup.

        I tried putting user back in and got this:
        Code:
        pwa@Lepiota:~$ mount /mediavault
        mount error: permission denied or not superuser and mount.cifs not installed SUID
        pwa@Lepiota:~$ ls -l $(which mount.cifs)
        -rwsr-sr-x 1 root root 23340 2008-10-10 12:56 /sbin/mount.cifs
        p

        Comment


          #5
          Re: Mounting cifs share from /etc/fstab on boot

          Mixing advise from 2 sources is not likely to work and it didn't.
          Quoting from man mount.cifs
          The mount.cifs utility attaches the UNC name (exported network resource) specified as service (using //server/share syntax, where "server" is the server
          name or IP address and "share" is the name of the share) to the local directory mount-point.

          I have trouble seeing that in hpmediavault:FileShare. If there is something I am not aware of, like a new syntax, please enlighten me. Otherwise I would suggest an fstab line something like
          //hpmediavault/FileShare /mediavault cifs rw,uid-1000,gid=1000

          and then /mediavault should be owned by user 1000 and group 1000. You may well need to supply a username and password for the share in which case you can add
          credentials=/home/user/.smb_creds to the options and then ~/.smb_creds looks like

          username=windows user
          password=windows password

          Comment


            #6
            I think it's a timing problem, not a permissions problem

            I changed the fstab line to use //hpmediavault/FileShare, but it made no difference. I also observed that if I execute mount -a as root once the system is up and running, /mediavault gets mounted correctly, so it seems very unlikely that faulty permissions are the cause of the problem.

            Apparently _netdev doesn't play well with CIFS, because /var/log/messages contained this line:
            Code:
            Mar 31 18:50:59 Lepiota kernel: [ 223.468987] CIFS: Unknown mount option _netdev
            Moreover, a grep search on that logfile looking for "mediavault" found nothing at all, so apparently CIFS mounts don't get logged except for certain errors they might generate.

            I think that what I need is code like the following in some system initialization file that gets executed as late as possible during bootup:
            Code:
            (while "network not up"; do sleep 10; done
            mount -a
            ) &
            The idea is to start a process that waits for the network to start up, then mounts everything again.
            But I don't know where to put that code. It would be even better if I could test explicitly if the mount succeeds.

            Comment


              #7
              Re: Mounting cifs share from /etc/fstab on boot

              That already happens. Look in /etc/init.d/mountnfs.sh.

              Comment


                #8
                Re: I think it's a timing problem, not a permissions problem

                As a temporary workaround, you can try putting your mount command in /etc/rc.local (this is executed last in the boot process) so your network should be up.

                I'd still check the order of Sxxmountall/Sxxnetworking/Sxxmountnfs startup links in /etc/rcS.d:
                Sxxmountall should run first (and exlude filesystems with _netdev option)
                then Sxxnetworking, and Sxxmountnfs should be run after networking.

                You can even try increasing the number for Sxxmountnfs (and Sxxmountnfs-bootclean) to bump them a little further in the boot process (you can try S60 and S61 respectively). This may give your network a bit more time to get up before trying to mount.

                Comment


                  #9
                  No mountnfs.sh in my copy of /etc/init.d at least

                  Code:
                  root@Lepiota:/etc/rcS.d# ls /etc/init.d/ | grep nfs
                  mountkernfs.sh
                  mountnfs-bootclean.sh
                  nfs-common
                  umountnfs.sh
                  waitnfs.sh
                  root@Lepiota:/etc/rcS.d# find /etc -name "*mountnfs*"
                  /etc/network/if-up.d/mountnfs
                  /etc/rcS.d/S46mountnfs-bootclean.sh
                  /etc/rc0.d/S31umountnfs.sh
                  /etc/rc6.d/S31umountnfs.sh
                  /etc/init.d/umountnfs.sh
                  /etc/init.d/mountnfs-bootclean.sh
                  root@Lepiota:/etc/rcS.d#
                  Perhaps there's actually a bug here (or at least a versioning problem).

                  In any event, I'll try just sticking a mount -a -t nfs,cifsl at the end of the bootup sequence. I don't see how it could hurt (or am I missing something?).

                  Comment


                    #10
                    Re: Mounting cifs share from /etc/fstab on boot

                    Quoting from the top of /etc/init.d/mountnfs.sh
                    # Description: Network file systems are mounted by
                    # /etc/network/if-up.d/mountnfs in the background
                    # when interfaces are brought up; this script waits
                    # for them to be mounted before carrying on.
                    #

                    Comment


                      #11
                      Re: Mounting cifs share from /etc/fstab on boot

                      Originally posted by mando_hacker
                      Quoting from the top of /etc/init.d/mountnfs.sh
                      # Description: Network file systems are mounted by
                      # /etc/network/if-up.d/mountnfs in the background
                      # when interfaces are brought up; this script waits
                      # for them to be mounted before carrying on.
                      #
                      Good pick. As it is, moving the startup link around is probably of little use.

                      Originally posted by pwabrahams
                      Perhaps there's actually a bug here (or at least a versioning problem).
                      Could be that things are different in Hardy 8.04 (the 'waitnfs' script could be doing the same thing as mountnfs...I don't have hardy so I can't check) anyway, you can try reinstalling "initscripts" package to make sure all the right scripts are installed.

                      In any event, I'll try just sticking a mount -a -t nfs,cifsl at the end of the bootup sequence. I don't see how it could hurt (or am I missing something?).
                      It shouldn't hurt. Sort of a "hackish workaround"™, but if it works.

                      Comment


                        #12
                        No mountnfs.sh even after reinstallation, waitnfs.sh doesn't do it

                        I reinstalled the initscripts and again did a search for mountnfs.sh. It wasn't there. So I looked at waitnfs.sh. It says:
                        Code:
                        # Short-Description: Wait for critical network file systems to be mounted
                        # Description:    Network file systems are mounted in the background when
                        #          interfaces are brought up; this script waits for
                        #          those among them which are critical for booting to be
                        #          mounted before carrying on.
                        #          Specifically, it will wait for file systems mounted
                        #          on /usr, /usr/*, /var, /var/*
                        #          This script WILL NOT wait on other network file which are
                        #          mounted elsewhere!
                        Since waitnfs.sh only looks at critical file systems, it does seem that the lack of mountnfs.sh is a versioning bug. Whether mountnfs.sh, if installed, would solve my problem remains to be shown.

                        Comment


                          #13
                          Re: Mounting cifs share from /etc/fstab on boot

                          The init scripts are not moved around. The way the init system works is that the scripts are in /etc/init.d and to select which get run when the system is entering or leaving a runlevel symbolic links are created in the runlevel directory, Sxxscript in /etc/rc2.d will cause script to run with the start argument when runlevel 2 is entered. Kxxscript in tha same directory will cause script to be run with the stop argument when runlevel 2 is entered.

                          The default runlevel for Debian (Kubuntu) is 2. /etc/rcS.d is for system scripts that need to run earlier.

                          /etc/init.d/mountnfs.sh is part of the package initscripts. I don't have an Intrepid box to check but I am almost certain that the file is there.

                          Comment


                            #14
                            Where is mountnfs.sh?

                            Originally posted by mando_hacker
                            /etc/init.d/mountnfs.sh is part of the package initscripts. I don't have an Intrepid box to check but I am almost certain that the file is there.
                            Could it be that the file is in Intrepid but not in Hardy (8.04.2)? I did a find search for it after reinstalling initscripts and still came up empty-handed.

                            Comment


                              #15
                              Re: Mounting cifs share from /etc/fstab on boot

                              It could be. I would be very surprised if that is true.
                              dpkg -L initscripts
                              will list the files in that package. If it is not in there then it is not.
                              dpkg -L initscripts | grep nfs
                              should make it very easy to see.

                              Comment

                              Working...
                              X