• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Mounting a network share at boot time.

billnot

Growing Old Disgracefully
Messages
242
Likes
0
My Satellite Setup
Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
My Location
Benitachell, Alicante, Spain
#1
A few weeks ago, in a thread on the 7025 forum entitled "expert setup", I posted a copy of my /etc/fstab with the idea of showing how to mount a network share (e.g. a folder on your PC) on the Dreambox at boot time.

Since then, and having learned a lot more about how the Dreambox does things, often quite differently from "standard" Linux, I now realise why this doesn't always work.

The problem is that /etc/fstab can be read, and the mount attempted, before the Samba client has started, and thus it will fail. The same trouble also befalls shares declared in automount.conf

The solution, which I have tried and tested with consistently good results on my 7025 follows. I have only tested it on the 7025. Locations and exact numerical files may differ for other models, but I see no reason why it shouldn't work for all. I'll explain the "why" after the "what".

Open a Telnet session.

(1) If you have a share mounted in /etc/fstab, remove it.

(2) Navigate to /etc/init.d

cd /etc/init.d

(3) Create a shell script named (e.g.) netmount.sh which should be something like this:
--------------------------------------------------------------
#! /bin/sh
#
# netmount.sh mounts all networkfilesystems.
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin

mount -t cifs -o user=
dream //192.168.0.2/share /media/shares/share

----------------------------------------------------------
user=dream
- specifies user name on the PC - substitute your user name for dream
//192.168.0.2/share - IP address of the PC with the folder to be shares and share is the share name given to it.
/media/shares/share This is a the directory you have created on your Dreambox to accommodate the share - it seems logical to me to create it under /media, but you can put it where you like as long as you specify it correctly in the script.

(4) chmod 755 your new script.

(5) Now navigate to /etc/rcS.d and do a directory listing

cd /etc/rcS.d
ls -l

You will see some (linked) files Sxxsomething where xx is a number.
S98configure should be the highest. Pick a number somewhere between the highest before that and 98 - in my case, S60hdparm_script.sh was the next highest, so I chose 90.
Now you need to do the clever bit and create a symbolic link back to the netmount.sh script you created above, naming it so that it's the last to execute before S98configure, i.e. using the number chosen above. Since I chose 90, my file will start S90, i.e.

ln -s /etc/init.d/netmounter.sh /etc/rsS.d/S90netmount.sh

To test it, make sure your PC share isn't mounted (by means of the mount command), and umount it if necessary, then call the linked file:

cd /etc/rcS.d
sh S90netmount.sh

Finally, check that your share is now mounted using mount

When you reboot, your PC share will automatically be mounted. netmount.sh can contain as many mount lines as you like, to mount multiple PC shares.

Why this works is because when booting Linux executes all the commands and scripts in the directories /etc/rc0.d to /etc/rc6.d and only handles /etc/rcS.d last (i.e. when runlevel 6 has been achieved). Also, it executes the commands within each directory in numerical order, so by linking our script to such a high numbered file, we guarantee it's virtually the last thing done on booting, thus ensuring that the Samba client is up and running when it happens.

It's working consistently for me, and I hope it's of help to you.



 

dig deep

Prince of Birthdays
Staff member
Messages
6,948
Likes
182
My Satellite Setup
Dream7020 and AZ Elite and a few DM800
My Location
Sweden
#2
A nice way around the boot-up problem :)
 
Messages
3
Likes
0
My Satellite Setup
DM500 Linux (clarkConnect) server
My Location
Netherlands
#3
Dear Billnot,

Does that trick also work for a networkdisk, on which are two directory's: one which requires a user and password and one which doesn't require user or password, to a directory on the one which doesn't need user and password.

PieterD
 

compufunk

Regular Member
Messages
1,658
Likes
1
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
#4
You should be able to do it by specifying your password.....
Code:
mount -t cifs -o user= dream password=YourPass //192.168.0.2/share /media/shares/share
I havent done this in a while, so dont know if this is the correct syntax.

Another way around the original problem is to just specify your mounts as normal in fstab, then issue the command in your startup script ....
Code:
mount -a
This will reload all mounts in your fstab file saving the need to specify every remote mount point in the startup script.
 
Messages
3
Likes
0
My Satellite Setup
DM500 Linux (clarkConnect) server
My Location
Netherlands
#5
One of the problems is that i get the message Cannot read /etc/fstab: No such file or directory after telnetting mount -a
After telnetting mount -t cifs -o user=xxx,password=yyy //192.168.2.68/openshare/dreamboxmovie /mnt/hdd i get the message
Mounting //192.168.2.68/openshare/dreamboxmovie on /mnt/hdd failed: Invalid argument.

Could it be i must first install a plugin?

PieterD
 

compufunk

Regular Member
Messages
1,658
Likes
1
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
#6
Unfortunately I cant replicate your setup/problem here at the minute.

All I can suggest is to use the automount option. I've never had any problems with it on my box. Even if the target server is switched off while the dreambox is booting, when you turn the server on and try to access the share, its available without any intervention.

Do it through the menu in...
BluePanel -> Extras / Setup -> Automount.

You can also do it by mofifying /etc/automount.conf.

My working file is as follows.....
Code:
nfs -fstype=cifs,ro,soft,udp,nolock,rsize=8192,wsize=8192,user=dreambox,pass=yyy ://192.168.1.2/d