What's new

Mount cifs share at bootup

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

garry13

Occasional Visitor
Hello everybody

I try to mount a NAS-Storage-Device during the boot on my RT-N66U.

I put the following into a "post-mount" script-file and stored it in "jffs/scripts" (after formating and restarting the router twice) :

#!/bin/sh
mount \\\\192.168.1.100\\ShareName /cifs1 -t cifs -o "username=User,password=Pass" (I changed this line to my conditions)

I made everything executable with:

chmod a+rx /jffs/scripts/*

The script works, if I start it manually. But it does not work during the boot process.

What is my mistake ?

Thanks Garry
 
Hello everybody

I try to mount a NAS-Storage-Device during the boot on my RT-N66U.

I put the following into a "post-mount" script-file and stored it in "jffs/scripts" (after formating and restarting the router twice) :

#!/bin/sh
mount \\\\192.168.1.100\\ShareName /cifs1 -t cifs -o "username=User,password=Pass" (I changed this line to my conditions)

I made everything executable with:

chmod a+rx /jffs/scripts/*

The script works, if I start it manually. But it does not work during the boot process.

What is my mistake ?

Thanks Garry

post-moiunt is only executed after a USB disk gets mounted, so it will never be executed if you don't have a USB disk plugged in.

services-start would be a better place to put this.
 
There is an USB-drive connected.
But renaming the script to "services-start" and rebooting did not work as well. :-(

Which of the user script is the last one used during booting ?

Best wishes
Garry
 
There is an USB-drive connected.
But renaming the script to "services-start" and rebooting did not work as well. :-(

Which of the user script is the last one used during booting ?

Best wishes
Garry

It's not sequentially-ordered, it's event-triggered. That's why chosing the correct script is important.

In your case, use the services-start, putting maybe a "sleep 30" command before you attempt mounting. Also, redirect the mount output to a temp file so you can see any error message resulting from it.
 
Hello everybody

I try to mount a NAS-Storage-Device during the boot on my RT-N66U.

I put the following into a "post-mount" script-file and stored it in "jffs/scripts" (after formating and restarting the router twice) :

#!/bin/sh
mount \\\\192.168.1.100\\ShareName /cifs1 -t cifs -o "username=User,password=Pass" (I changed this line to my conditions)

I made everything executable with:

chmod a+rx /jffs/scripts/*

The script works, if I start it manually. But it does not work during the boot process.

What is my mistake ?

Thanks Garry

See here a working script
http://forums.smallnetbuilder.com/showpost.php?p=59904&postcount=2
http://forums.smallnetbuilder.com/showpost.php?p=61104&postcount=17
 
Thank You guys for Your suggestions.
Adding "sleep 30" did the trick.

Great software by the way...
 
apologies on bumping an old thread. I too am new to Merlin's build, and am trying to get a cifs automounted on reboot. I've tried inserting an entry to my services-start script, but it doesn't autostart. Could someone point me in the right direction stepwise? Thanks!
 
Try with post-mount script and add a 30 seconds or more delay


Hi! Thanks for the reply.

I’ve tried with 60 sec sleep on the start services script. Will try with the post mount script and report back. Thanks!

Edit - What I have is

#!/bin/sh

Sleep 60

mount \\\\192.168.1.100\\ShareName /cifs1 -t cifs -o "username=User,password=Pass" (I changed this line to my conditions)



Doesn't seem to work. Could anyone possibly shed some light on how to get a Remote Share CIFS automounted on boot?

THanks!
 
Last edited:
The mount command you have used was a made up example to show the form for the command.
YOUR mount command WILL be specific to your setup and the cif share you have created.

You need to know the name you have used to share the cif.
You need to know the Username & Password associated with the cif.
You need to know the location the cif share should mount on (The directory name i.e. /cif or /SharedData or whatever you want to call it.)

Using commands blindly MAY work NOT as intended and could do things that you don't WANT !!!
i.e. Change or delete things that you NEED to allow the Router to work. !!!
If you don't understand what the command does you will not understand what you changed by 'accident'.


You need to change 192.168.1.100 to the IP address of the Machine that is hosting the cif share, it should be in the IP Address range of the Router or you will need to setup routing to the machine.

The ShareName must match the name used to share your cif, change the word 'ShareName' to the correct value.

/cif1 must exist in your Router Filesystem, it is where the 'Remote Share' will mount.
(Change it to whatever you need as long as it does not overwrite an existing directory you need and is somewhere you CAN define a new mountpoint. Create it first.)

User & Pass must be changed to the Username & Password defined for your cif.

Please lookup on Google/Bing/DuckDuckGo/Startpage etc the Manpage for the 'Mount' command & Sample/How to Pages to try to understand what you are doing.
You can still ask questions but hopefully from a position where, both, what you want to do and the answers you get can be understood better.
 
Edit -
The mount command you have used was a made up example to show the form for the command.
YOUR mount command WILL be specific to your setup and the cif share you have created.

You need to know the name you have used to share the cif.
You need to know the Username & Password associated with the cif.
You need to know the location the cif share should mount on (The directory name i.e. /cif or /SharedData or whatever you want to call it.)

Using commands blindly MAY work NOT as intended and could do things that you don't WANT !!!
i.e. Change or delete things that you NEED to allow the Router to work. !!!
If you don't understand what the command does you will not understand what you changed by 'accident'.


You need to change 192.168.1.100 to the IP address of the Machine that is hosting the cif share, it should be in the IP Address range of the Router or you will need to setup routing to the machine.

The ShareName must match the name used to share your cif, change the word 'ShareName' to the correct value.

/cif1 must exist in your Router Filesystem, it is where the 'Remote Share' will mount.
(Change it to whatever you need as long as it does not overwrite an existing directory you need and is somewhere you CAN define a new mountpoint. Create it first.)

User & Pass must be changed to the Username & Password defined for your cif.

Please lookup on Google/Bing/DuckDuckGo/Startpage etc the Manpage for the 'Mount' command & Sample/How to Pages to try to understand what you are doing.
You can still ask questions but hopefully from a position where, both, what you want to do and the answers you get can be understood better.


Thanks for the lengthy reply. Apologies on not being clear before this. I've actually mounted the cifs manually prior to this with the correct address of the network share. It mounts fine manually. The problem i'm having is getting it to automount. I've edited the services-start script, including the modded command after the shebang and a sleep. It weirdly isn't starting with each reboot.
 
Sorry for the long Reply ...... it looked like you had tried a 'non-working' command line. :)

Try the following:

Can you add a redirect from the command to a file that you can read after restart of the router.
[> /tmp/xxxx/xxxx/mountcommand-output.txt] ..... to catch any errors.

Also Put Echo statements Bracketing the commands in the startup files file to show in the Syslog where it got to etc.

Either the command is not running, there is some fault in the parameters or 'Pathing' .... ensure the mount command can be found by explicitly putting in the 'Fullpath' before the mount command.
[Belt and Braces incase pathing is the problem]

Let me know what you get ...... thanks.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top