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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
10-28-2005, 04:04 PM
|
#1
|
|
Member
Registered: Oct 2005
Posts: 43
Rep:
|
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.
|
|
|
|
10-28-2005, 04:15 PM
|
#2
|
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 376
Rep:
|
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.)
|
|
|
|
10-28-2005, 04:21 PM
|
#3
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-28-2005, 04:37 PM
|
#4
|
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 376
Rep:
|
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
|
|
|
|
10-28-2005, 05:02 PM
|
#5
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-28-2005, 05:03 PM
|
#6
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
I forgot to tell you.
My Manager wants to do Open the Terminal and mount if when it needed.
Thanks,
Kal
|
|
|
|
10-28-2005, 05:08 PM
|
#7
|
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Debian, FreeBSD, Ubuntu (desktop)
Posts: 3,859
Rep: 
|
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.
|
|
|
|
10-28-2005, 05:19 PM
|
#8
|
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 376
Rep:
|
Anomie is right. Assuming you need the Samba volume, 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.
|
|
|
|
10-28-2005, 05:22 PM
|
#9
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-28-2005, 06:17 PM
|
#10
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-28-2005, 07:52 PM
|
#11
|
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 376
Rep:
|
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.
|
|
|
|
10-30-2005, 12:36 PM
|
#12
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-31-2005, 10:40 AM
|
#13
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
10-31-2005, 11:04 AM
|
#14
|
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 376
Rep:
|
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.
|
|
|
|
10-31-2005, 12:43 PM
|
#15
|
|
Member
Registered: Oct 2005
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:54 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|