1 (edited by Goblox 2011-11-06 09:57:50)

Topic: Fstab not mounting cifs at boot or through CLI

Hi, this is my first post here so I want to say thanks to everyone for all the info that is up. I have been able to solve most of my problems myself so far by just searching and reading others posts.

I am having an issue I cannot find any information about. I have a network share that I can access just fine and mount using either mount.cifs or mount -t cifs. When I try to mount it using fstab I am having some issues though.

When I mount using mount.cifs or mount -t it works just fine, this is the output of running the mount command with no arguments:

root@OpenWrt:~# mount -t cifs //192.168.1.9/share ~/mount/nas/share -o guest
root@OpenWrt:~# mount
rootfs on / type rootfs (rw)
(snip)
//192.168.1.9/share on /root/mount/nas/share type cifs (rw,mand,nodiratime,unc=\\192.168.1.9\share,username=root,domain=,rsize=16384,wsize=16384)

But I have tried to include this in my fstab config file using the following config:

config global automount
        option from_fstab 1
        option anon_mount 1

config global autoswap
        option from_fstab 1
        option anon_swap 0

config mount
        option target   /root/mount/nas/share
        option device   //192.168.1.9/share
        option fstype   cifs
        option options  rw,mand,nodiratime,unc=\\192.168.1.9\share,username=root,domain=,rsize=16384,wsize=16384
        option enabled  1
        option enabled_fsck 0

config swap
        option device   /dev/sda2
        option enabled  0

Now, the drive doesn't mount on reboot (which is why I am here) but it also doesn't mount when I run /etc/init.d/fstab start or restart. In my logread output there are no error messages other than a warning about not being able to find fsck (which shouldn't be an issue because it isn't enabled in fstab) and I also get that message running fstab start or restart.

I have tried the fix mentioned here http://wiki.openwrt.org/doc/uci/fstab#notes regarding the commenting out of that line in fstab and creating a symbolic link, but it hasn't improved. In fact, now when I run restart or stop I get:

swapoff: /etc/fstab: No such file or directory

which I assume is ecause fstab hasn't been able to successfully mount the drive in the first place?


Anyway I am running out of avenues of investigation here. I can't get any error messages or details in the log as to why it isn't mounting, I can't get it to mount at all using fstab yet I have no issues mounting and accessing it using the mount command.

Can someone tell me if there are any other ways of investigating why this isn't mounting, or possibly correct my config file for me? I have tried it with a lot of different options too in the options line but I have had no luck at all. Oh sorry I should add that I am using 10.03.

Thanks in advance if anyone is able to help.

edit: just wanted to add that I have also checked the dmesg output and there is nothing output there either

Re: Fstab not mounting cifs at boot or through CLI

Goblox wrote:

I am having an issue I cannot find any information about. I have a network share that I can access just fine and mount using either mount.cifs or mount -t cifs. When I try to mount it using fstab I am having some issues though.

1. check the order of scripts executed at startup with 'ls /etc/rc.d'
2. write a hotplug script that mounts when your network interface goes up and umounts when it goes down
3. ????
4. profit

All the waiting and then the CPU ventilator brrrrrr all the time.

Re: Fstab not mounting cifs at boot or through CLI

Thank you so much! Solved my problem instantly, who needs fstab anyway eh hehe


I love this community, thanks again.

4 (edited by rdmitry 2012-01-24 14:54:17)

Re: Fstab not mounting cifs at boot or through CLI

Goblox wrote:

Thank you so much! Solved my problem instantly, who needs fstab anyway eh hehe


I love this community, thanks again.

Hi, I've just faced with the same problem - can't mount cifs share during the initial bootup process. fstab doesn't work at all. hotplug script works, but doesn't mount the share. After the boot process is accomplished I can mount the share without any problems.

The device is WR941ND v2.2 running Backfire 10.03.1

The contents of /etc/hotplug.d/iface/21-cifs-mount is as follows

#!/bin/sh
# This script is executed as part of the hotplug event with
# HOTPLUG_TYPE=iface, triggered by various scripts when an interface
# is configured (ACTION=ifup) or deconfigured (ACTION=ifdown).  The
# interface is available as INTERFACE, the real device as DEVICE.

[ "$DEVICE" == "lo" ] && exit 0

. /etc/functions.sh
case "$ACTION" in
    ifup)
        if [ "$DEVICE" == "br-lan" ]
        then  /bin/mount -t cifs //10.20.251.23/router /cifs -o user=router,password=password09,nounix,noserverino
        fi         
    ;;
    ifdown)
        if [ "$DEVICE" == "br-lan" ] 
        then /bin/umount  /cifs
        fi
    ;;
esac

the contents of /etc/hotplug.d/iface directory is as follows:

root@router-2:~# ls -l /etc/hotplug.d/iface/
-rw-r--r--    1 root     root          242 Nov 14 13:34 00-netstate
-rw-r--r--    1 root     root         3622 Nov 14 13:34 10-routes
-rw-r--r--    1 root     root          537 Dec 20 21:53 20-firewall
-rw-r--r--    1 root     root          608 Jan 24 17:26 21-cifs-mount

My part of /etc/config/fstab is as follows:

config mount                                                                                                                          
        option target   /cifs                                                                                                          
        option device   //10.20.251.23/router                                                                                         
        option fstype   cifs                                                                                                          
        option options  user=router,password=password09,nounix,noserverino,rw
        option enabled  1                                                                                                             
        option enabled_fsck 0                                                                                                         
        option is_rootfs 0

The question is what's wrong in my config?

Any help would be very much appreciated.
Thank you, Dmitry

Re: Fstab not mounting cifs at boot or through CLI

A little update. When I substituted /bin/mount -t cifs to /sbin/mount.cifs in hotplug script, Igot an error

mount error: cifs filesystem not supported by the system
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

which means, that cifs mount functions are unavailable at the network initialization point.
Now the question is when they become available during initial bootup process?

Regards, Dmitry

Re: Fstab not mounting cifs at boot or through CLI

rdmitry wrote:

A little update. When I substituted /bin/mount -t cifs to /sbin/mount.cifs in hotplug script, Igot an error

mount error: cifs filesystem not supported by the system
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

which means, that cifs mount functions are unavailable at the network initialization point.
Now the question is when they become available during initial bootup process?

Regards, Dmitry

this script is proven to work

root@Alix:~# cat /etc/hotplug.d/iface/21-pub
#!/bin/sh

[ "$DEVICE" == "lo" ] && exit 0

. /etc/functions.sh
case "$ACTION" in
  ifup)
    if [ "$DEVICE" == "br-lan" ]; then
      mount -t cifs //192.168.0.100/pub /mnt/pub -o user=flux,nounix,noserverino
    fi
    ;;
  ifdown)
    if [ "$DEVICE" == "br-lan" ]; then 
      umount  /mnt/pub
    fi
    ;;
esac
All the waiting and then the CPU ventilator brrrrrr all the time.

Re: Fstab not mounting cifs at boot or through CLI

It makes more sense to check for "$INTERFACE" == "lan" instead of "$DEVICE" == "br-lan", then it will also work if lan isn't a bridge for whatever reason.

Re: Fstab not mounting cifs at boot or through CLI

Hi, I've just made it possible to use fstab for network mounts like cifs, smb and nfs. You have to add one more check in libmount_find_device_by_id() function  in /lib/functions/block.sh
Now it looks like

libmount_find_device_by_id() {                                                                                                                                  
        local uuid="$1"
        local label="$2"
        local device="$3"
        local cfg_device="$4"
        local found_device                                                                                                                                      

        if [ -n "$uuid" ]; then
                found_device="$(libmount_find_token "UUID" "$uuid")"
        elif [ -n "$label" ]; then
                found_device="$(libmount_find_token "LABEL" "$label")"
        elif [ "$device" = "$cfg_device" ]; then
                found_device="$device"
        elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
                found_device="$cfg_device" 

## makes it possible to mount network shares

        elif [ "${cfg_device:0:2}" = "//" ] || [ -n $(/bin/echo $cfg_device | /bin/grep -iq ":") ]; then
                found_device="$cfg_device" 
        fi
        [ -n "$device" ] && [ "$device" != "$found_device" ] && {
                found_device=""
        }
        echo "$found_device"
}

However, hotplug script still doesn't work on boot. I think I have to to build custom backfire image with cifs/nfs modules included.

Regards, Dmitry

Re: Fstab not mounting cifs at boot or through CLI

question;
what is the difference between putting a script in /etc/hotplug.d/net/ and in /etc/hotplug.d/iface/ ?

10 (edited by plasticassius 2013-01-19 11:31:13)

Re: Fstab not mounting cifs at boot or through CLI

Here is another idea similar to /etc/hotplug.d script, but uses /etc/init.d/mountcifs:

#!/bin/sh /etc/rc.common

START=90

start() {
    mkdir -p /mnt/ext /mnt/sat
    mount -o user=,password=,noatime,nodiratime -t cifs //192.168.1.2/external /mnt/ext
    mount -o user=,password=,noatime,nodiratime -t cifs //192.168.1.4/harddisk /mnt/sat
}

stop() {
    umount /mnt/ext /mnt/sat
} 

Then use:

/etc/init.d/mountcifs enable
/etc/init.d/mountcifs start

This script works well for me. Also, similar scripts can start/stop many other things.

Re: Fstab not mounting cifs at boot or through CLI

rdmitry wrote:

Hi, I've just made it possible to use fstab for network mounts like cifs, smb and nfs. You have to add one more check in libmount_find_device_by_id() function  in /lib/functions/block.sh
Now it looks like

libmount_find_device_by_id() {                                                                                                                                  
        local uuid="$1"
        local label="$2"
        local device="$3"
        local cfg_device="$4"
        local found_device                                                                                                                                      

        if [ -n "$uuid" ]; then
                found_device="$(libmount_find_token "UUID" "$uuid")"
        elif [ -n "$label" ]; then
                found_device="$(libmount_find_token "LABEL" "$label")"
        elif [ "$device" = "$cfg_device" ]; then
                found_device="$device"
        elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
                found_device="$cfg_device" 

## makes it possible to mount network shares

        elif [ "${cfg_device:0:2}" = "//" ] || [ -n $(/bin/echo $cfg_device | /bin/grep -iq ":") ]; then
                found_device="$cfg_device" 
        fi
        [ -n "$device" ] && [ "$device" != "$found_device" ] && {
                found_device=""
        }
        echo "$found_device"
}

However, hotplug script still doesn't work on boot. I think I have to to build custom backfire image with cifs/nfs modules included.

Regards, Dmitry

I have same issue
Any solution on this?

12 (edited by exgenui 2013-12-18 20:47:38)

Re: Fstab not mounting cifs at boot or through CLI

flux wrote:
rdmitry wrote:

A little update. When I substituted /bin/mount -t cifs to /sbin/mount.cifs in hotplug script, Igot an error

mount error: cifs filesystem not supported by the system
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

which means, that cifs mount functions are unavailable at the network initialization point.
Now the question is when they become available during initial bootup process?

Regards, Dmitry

this script is proven to work

root@Alix:~# cat /etc/hotplug.d/iface/21-pub
#!/bin/sh

[ "$DEVICE" == "lo" ] && exit 0

. /etc/functions.sh
case "$ACTION" in
  ifup)
    if [ "$DEVICE" == "br-lan" ]; then
      mount -t cifs //192.168.0.100/pub /mnt/pub -o user=flux,nounix,noserverino
    fi
    ;;
  ifdown)
    if [ "$DEVICE" == "br-lan" ]; then 
      umount  /mnt/pub
    fi
    ;;
esac

Hi Flux, I already follow this step but still not work ( sorry I'm new). is there any additional commands at "hotplug2.rules" ,"hotplug2-common.rules" or "hotplug2.init.rules" must be added to make this work?
as jow advise, I changed  "$DEVICE" == "br-lan to "$INTERFACE" == "lan" but still not work on me.