LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-26-2008, 01:58 PM   #1
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Rep: Reputation: 32
Question Mounting SMBFS at Boot time via rcN.d


I have created the following bash script in /etc/init.d called mnt_gcctfs1.sh with the following contents.
Code:
#! /bin/sh
case "$1" in
start)
echo "Mounting GCCTFS1..."
mount -t smbfs //gcctfs1/engineer /media/engineer -o username=uname,password=pword,iocharset=utf8,file_mode=0777,dir_mode=0777
;;
stop)
echo -n "Unmounting GCCTFS1..."
umount /media/engineer
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
I can run this from the command line and it works just fine and mounts and unmounts the share appropriately.
Code:
./mnt_gcctfs1.sh start|stop
I ran the update-rc.d utility:
Code:
root@gcnpd:/etc/init.d#  update-rc.d mnt_gcctfs1.sh start 99 2 3 4 5 . stop 01 0 1 6 .
 Adding system startup for /etc/init.d/mnt_gcctfs1.sh ...
   /etc/rc0.d/K01mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc1.d/K01mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc6.d/K01mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc2.d/S99mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc3.d/S99mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc4.d/S99mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
   /etc/rc5.d/S99mnt_gcctfs1.sh -> ../init.d/mnt_gcctfs1.sh
I rebooted expecting to find the share mounted and it is not.
I can again run the script manually from the command line, but it does not work during the boot process.

Any thoughts?

Chris
 
Old 06-30-2008, 01:10 PM   #2
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Original Poster
Rep: Reputation: 32
Still looking for some help on this.

Anyone? Anyone?

Chris
 
Old 06-30-2008, 01:37 PM   #3
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Rep: Reputation: 17
Try "man init" and viewing /etc/inittab and /etc/init.d/rc
See what these might tell you...
 
Old 06-30-2008, 03:39 PM   #4
Ajax4Hire
LQ Newbie
 
Registered: May 2004
Location: sol 3 (3rd planet from sun)
Distribution: Redhat 9.0
Posts: 8

Rep: Reputation: 0
This is a path problem...

When you run from sh(bash) you path= is more complete.
When your init/inittab launches, path=/bin:/usr/bin:/sbin:/usr/sbin

I bet this is not enough.
I bet there are executables outside the standard basic init path that your script(s) need.

A 2nd place to look is your kernel.
Do you have smbfs/cifs compiled directly in or as a module.
If module, when is module loaded.

Finally, add some script outputs and use "tee" to capture output to a file say in var/log/mnt_gcctfs1.out
echo out the Time/Date, path, runlevel, the $0, $#, $* inputs and anything else that might be helpful. For example, I include in all cron/init scripts:

#!/bin/sh
CMD0="`basename $0`"
LOGX="/var/log/${CMD0}.log"
#
echo "CMD0=$CMD0 $*" | tee -a $LOGX
echo " now=`date +\"%Y-%m-%d_%a %H:%M:%S\"`" | tee -a $LOGX
echo "LOGX=$LOGX" | tee -a $LOGX
echo "PATH=$PATH" | tee -a $LOGX
 
Old 06-30-2008, 04:13 PM   #5
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Original Poster
Rep: Reputation: 32
Thanks. That looks like some good info.

I installed smbfs after the install via apt so I'm sure it is a module.


I put your code at the top of my script. I ran the script manually from the command line. Once with the start argument and twice with the stop argument.
Here's what I get:
Code:
CMD0=mnt_gcctfs1.sh start
now=2008-06-30_Mon 17:02:51
LOGX=/var/log/scripts/mnt_gcctfs1.sh.log
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
CMD0=mnt_gcctfs1.sh stop
now=2008-06-30_Mon 17:03:26
LOGX=/var/log/scripts/mnt_gcctfs1.sh.log
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
CMD0=mnt_gcctfs1.sh stop
now=2008-06-30_Mon 17:04:10
LOGX=/var/log/scripts/mnt_gcctfs1.sh.log
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
I then rebooted. The script should be getting called sometime during boot process.
The contents of that file did not change.

Does anyone know if Unbuntu uses something different thatn the rcN.d process?
 
Old 06-30-2008, 04:32 PM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Do you know if the script is bein run OK? Do a simple test like "touch /home/test.touch" or something in there.

My initial though is you are running this before your network is up, which is what the _netdev mount option is for. See http://www.linuxquestions.org/questi...tartup-651969/ (although this thread is working for some reason that stumps me at present)
 
Old 07-03-2008, 10:12 AM   #7
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Original Poster
Rep: Reputation: 32
Now on to a related bash scripting problem

I wound up putting a call to this script in /etc/cd.local and this seems to work fine.

I now have created a script to test to see if the share is mounted.
Code:
#!/bin/bash

SUCCESS=`mount|grep engineer|cut -d '/' -f3`
FAIL=`mount|grep engineers|cut -d '/' -f3`
echo $SUCCESS
echo #FAIL

if [ -n $SUCCESS ]
        then
        echo "Engineer Mounted."
else
        echo "Engineer NOT Mounted."
fi

if [ -n $FAIL ]
        then
        echo "Engineers Mounted."
else
        echo "Engineers NOT Mounted."
fi
This is just a test script.
If I run mount I get:
Code:
root@gcnpd:~/scripts# mount 
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.22-14-generic/volatile type tmpfs (rw)
securityfs on /sys/kernel/security type securityfs (rw)
//gcctfs1/engineer on /media/engineer type smbfs (rw)
The last line is the one of interest.
Here are the results of a run of my script:
Code:
root@gcnpd:~/scripts# ./temp.sh 
gcctfs1

Engineer Mounted.
Engineers Mounted.
Why does the $FAIL case "succeed"?

Any thoughts?

Chris
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting a nfs partition on boot time wjleon Linux - Newbie 1 05-02-2005 11:12 AM
Mounting at boot time... troubles Alotau Linux - Newbie 13 01-22-2005 05:47 AM
why smbfs not starting up at boot time? gkogut Linux - Networking 2 11-10-2003 05:47 PM
Swap File mounting at boot time sneakerski Arch 2 08-20-2003 09:28 PM
Error Mounting a boot time aarroyob Linux - Newbie 3 06-06-2003 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration