Proper way to mount CIFS share?

Hello community,

I've used to mount a CIFS share after booting the router with simply editing my mounts to /etc/fstab and enabling the fstab service (service fstab enable).
I think since 18.06.02 (not quite sure), this file has been marked as obsolete. I checked the file itself:
root@OpenWrt:~# cat /etc/init.d/fstab

#!/bin/sh /etc/rc.common
# (C) 2013 openwrt.org

START=40

boot() {
        /sbin/block mount
}

start() {
        echo "this file has been obsoleted. please call \"/sbin/block mount\" directly"
}

stop() {
        /sbin/block umount
}

What is the proper way to mount a CIFS share on boot? Sure, I can add my mount command to /etc/rc.local and I also found some crazy approach with a "hotplug-script" (?!) here.

Both ways however doesn't seem as the proper approach to me - might be just me however.

Could somebody please tell me the proper approach of mounting a CIFS share on/right after boot?

Thanks a lot!

1 Like

At least as I have read that same code a few times, it is start that is obsoleted, not boot

(Please correct me if I am wrong on this!)

1 Like

Well, at least /sbin/block mount does not mount my configured share in /etc/fstab. It does mount however (which is already mounted) the "base filesystem" of openwrt (I have extroot on USB).

1 Like

If you manually run /sbin/block mount after the system is fully up, does it mount the share? If so, it seems like a timing issue.

1 Like

No it does not. Tried that already:

root@OpenWrt.dmz:~$ mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/sda1 on /overlay type ext4 (rw,relatime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
ubi1:syscfg on /tmp/syscfg type ubifs (rw,relatime,ubi=1,vol=0)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/ubi0_1 on /rwm type ubifs (rw,relatime,ubi=0,vol=1)
root@OpenWrt.dmz:~$ /sbin/block mount
block: /dev/ubiblock0_0 is already mounted on /rom
block: /dev/ubi0_1 is already mounted on /rwm
block: /dev/sda1 is already mounted on /overlay
root@OpenWrt.dmz:~$ mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/sda1 on /overlay type ext4 (rw,relatime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
ubi1:syscfg on /tmp/syscfg type ubifs (rw,relatime,ubi=1,vol=0)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/ubi0_1 on /rwm type ubifs (rw,relatime,ubi=0,vol=1)
root@OpenWrt.dmz:~$ 
1 Like

What about mount -a ?

1 Like

yea sure, mount -a does the job - but is that the proper way of mounting a CIFS share in OpenWrt? and does mount get triggered when booting? (can't reboot right now, backups running)
I expected something via uci - if thats not intended, I'll stick with /etc/rc.local - I just was wondering about the proper way as I want to understand OpenWrt and use it as intended instead of "making things work", which might break during an upgrade/update.

1 Like

Same here. I'm with the same issue and before creating a thread I googled and found this one.

mount.cifs //192.168.49.104/nas /share/nas104 -o ip=192.168.49.104,user=********,pass=********,dom=*********,uid=1000,gid=100,forceuid,forcegid,file_mode=0775,dir_mode=0775,iocharset=utf8

works on the fly

//192.168.49.104/nas /share/nas104 cifs ip=192.168.49.104,user=********,pass=********,dom=******,uid=1000,gid=100,forceuid,forcegid,file_mode=0775,dir_mode=0775,iocharset=utf8 0 0

added to /etc/fstab followed by mount -a works.

But when I reboot it's not mounted.

mount lists it among other mounts.

What's the best practice to do it? Or where should I add a custom script to run as soon as possible on boot?

If I have to run mount -a I'd rather run the mount.cifs command.

Did any of you manage to figure this out?

I added this to System > Startup > Local Startup but it's still not automatically mounting :frowning:

wait 30
mount -t cifs //192.168.2.247/share /mnt/share/ -o user=share,pass=password
1 Like