LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-28-2005, 04:04 PM   #1
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Rep: Reputation: 15
How to write a script for automatic mount


Hi All,

I have a Question. I am very new to the LInux. Please help me.

My question is :

After Rebooting the system. I have to mount manually for the Scripts.

I don't want to do that.

I would like to write a script for mount automatically.


Thanks for helping me.

Kal.
 
Old 10-28-2005, 04:15 PM   #2
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Describe your file systems in /etc/fstab. All those entries will automatically be mounted by "boot -a", which runs at boot time, unless they explicitly have the "noauto" option. See fstab(5), mount(8).

In case you are very new, the last two are references to manual pages. Just type "man fstab" or "man mount". (They are in sections 5 (file formats) and 8 (administrative tools), respectively.)
 
Old 10-28-2005, 04:21 PM   #3
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Automatic Mount

Thanks for prompt reply.

I looked at /etc/fstab, I have noauto option.

I don't want to change to noauto to auto. My Manager was saying don't change.

He was saying write a script.

Thanks,
kal
 
Old 10-28-2005, 04:37 PM   #4
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Hi Kal,

In case you can convince your manager later, you'd just remove the "noauto" option. There is no "auto" option. Here's my /etc/fstab.
Code:
LABEL=/                 /                       ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=/usr              /usr                    ext3    defaults        1 2
/dev/sda3               swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
I think it's fairly typical that only removable media have the "noauto" option, because they may not be in their drive at boot time. That's how I think most of us do it.

Maybe I didn't understand "for the Scripts".
Anyway, if you want to write a script, just use several "mount" commands.

Quigi
 
Old 10-28-2005, 05:02 PM   #5
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Hi,

See my etc/fstab, If you look my username is kmandavilli.

LABEL=/ / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/usr /usr ext3 defaults 1 2
/dev/sda3 swap swap defaults 0 0

//sm-file-01/devdata /filesrv smbfs noauto, ip=10.1.4.29, username=kmandavilli,workgroup=agi,fmask=0777,dmask=0777 0 0

/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0


Forget "For my Scripts".

Thanks,
Kal
 
Old 10-28-2005, 05:03 PM   #6
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
I forgot to tell you.

My Manager wants to do Open the Terminal and mount if when it needed.

Thanks,
Kal
 
Old 10-28-2005, 05:08 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
That it's in your /etc/fstab makes this a pretty simple script. Something like
Code:
#!/bin/sh
mount /partition_here
exit 0
should do, unless you want to specify options that aren't already in the fstab.

You might consider what you want to happen if the mount fails.

Last edited by anomie; 10-28-2005 at 05:09 PM.
 
Old 10-28-2005, 05:19 PM   #8
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Anomie is right. Assuming you need the Samba volume,
Code:
mount /filesrv
is all you need.

I don't have experience with automounters, but you might want to look at automount(8). It might be possible to automatically mount what you need, and get it unmouted automatically too, e.g., after 8 minutes of inactivity.
 
Old 10-28-2005, 05:22 PM   #9
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Thank you So much for the prompt reply.

After mounting ex: mount /filesrv.

It will ask Enter Password: I have to enter manually.

I would like to do enter password automatically after mounting.


Thanks,
Kal
 
Old 10-28-2005, 06:17 PM   #10
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Thank you So much for the prompt reply.

After mounting ex: mount /filesrv.

It will ask Enter Password: I have to enter manually.

I would like to do enter password automatically after mounting.


Thanks,
Kal
 
Old 10-28-2005, 07:52 PM   #11
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
I haven't used samba mount. It's effected by /sbin/mount.smbfs. Maybe you can supply the password as an option? Maybe

echo xyzzy | mount /filesrv

would work? I don't know.
 
Old 10-30-2005, 12:36 PM   #12
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Hi All,

Thank you so much for Every body.

Actually I am thinking If I open other terminal using Xterm command.

After we open the terminal, how to mount /filesrv using script.

Thanks,
kalyani
 
Old 10-31-2005, 10:40 AM   #13
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Hi,

My script:

#!/bin/sh

xterm #It will open the Other Terminal.
mount /filesrv #It will mount the filesrv

In between these lines I have to insert the cursor option.

How can I change the Cursor in script
 
Old 10-31-2005, 11:04 AM   #14
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Your script will open an xterm, in which a shell will run, and you can do whatever you like. Only after you exit from that shell, the xterm itself will exit, and then mount will happen. Probably that's not what you want. What do you want to happen? What's the purpose of the xterm?

To make the mount happen in the xterm,
Code:
xterm -e "mount /filesrv; sleep 5"
The sleep command will give you a moment to see any error message. Otherwise, if there is a problem, the message disappears together with the xterm. (I'd avoid the xterm.) Once you know it works, you can take "; sleep 5" out.

What's the cursor option? Do you want to manipulate the mouse pointer in order to give the new window the keyboard focus? (A) The new xterm gets the focus anyway (at least in my setup, FC2). (B) Manipulating GUI stuff from a script is usually not necessary, and hardly ever desirable.
 
Old 10-31-2005, 12:43 PM   #15
Kalyani1
Member
 
Registered: Oct 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Hi Quigi,

Thank you somuch for your help.

Code is working fine.

I got an other idea

I have 3 scripts to run at a time.

But My code is

xterm -e mount /filesrv
xterm -e param.sh
xterm -e makePRN.sh
xterm -e relesechecker.sh

It's running file, but it's running first param.sh, after that it's running makePRN.sh.
I wold like run the scripts at a time.

Thanks,
kal
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Automatic mount steelneck Linux - Software 2 11-26-2005 11:39 AM
automatic mounting and write acces oldforce Ubuntu 2 04-19-2005 04:51 PM
Can't WRITE to USB stick, Mount OK NO WRITE! ClericPreston Linux - Newbie 4 12-04-2004 10:43 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
HELP! Error from mount: drive is write-protected... won't mount writeable. system Linux - General 2 12-27-2001 09:08 PM


All times are GMT -5. The time now is 01:17 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration