billnot
Growing Old Disgracefully
- Joined
- May 23, 2003
- Messages
- 242
- Reaction score
- 0
- Points
- 0
- Age
- 84
- My Satellite Setup
- Famaval 3,1, IP9000HD plus other FTA and Linux boxes - Astra 1&2, Hotbird, Hispasat
- My Location
- Benitachell, Alicante, Spain
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.
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.