LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-23-2006, 09:17 AM   #1
Rustylinux
Member
 
Registered: Mar 2006
Posts: 177

Rep: Reputation: 30
Help writing script file to mount / mount hard drive


Hey,

Just need some help writing a script to mount / unmount a hot swap hard drive that I have in my system. I recently put in a hot swap drawer for one of my sata drives and need to figure out how to write a script so it mounts / unmounts it. Any help would be greatly appricated.


Thanks
 
Old 06-23-2006, 09:27 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
what do you need a script for? what's wrong with just using mount and umount?

actually... you might be interested in autofs, where if a drive is not used for 60 seconds or something, it is unmounted automatically. also mounted on access, not on boot... might be what you're really after.
 
Old 06-23-2006, 10:52 AM   #3
Rustylinux
Member
 
Registered: Mar 2006
Posts: 177

Original Poster
Rep: Reputation: 30
The reason why I want to write a script for it is for backups. The drive was put into the system so it can do backups when i'm out on the weekends. I was planning on writing a script and then just getting scheduled tasks to run it at a certian time to mount the drive before the backup occurs and to unmount it after it is finished.
 
Old 06-23-2006, 11:01 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well that's just a bunch of standard commands in a file, there's nothign particuarly interesting about the way you would umount it here.
 
Old 06-27-2006, 09:21 AM   #5
Rustylinux
Member
 
Registered: Mar 2006
Posts: 177

Original Poster
Rep: Reputation: 30
Thats what I would like some help on. Would it just be a simple mount and unmount in the script file?
 
Old 06-27-2006, 09:31 AM   #6
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
you wouldn't need a script, as all it would be doing is giving the mount/umount commands to the shell, which you can type anyway.

Personally i'd just add a line to /etc/fstab with the noauto option, check the file for a good idea of what a line looks like, pretty self expanatary. Using no auto means its not mounted at boot, whilst that would be good if its attached when the box is booted, it can take a few extra seconds/mins for it to crap out on the mount and carry on booting.

Then you could just type mount <mount_point> or umount <mount_point> as the mount command searches /etc/fstab (and mtab but i never use that) for a line with that mount point, and gets the options off of there.

You could use a script if you wanted a cron job whereby the mount/umount commands are executed on a timer
 
Old 06-27-2006, 09:34 AM   #7
binary_y2k2
Member
 
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Blog Entries: 1

Rep: Reputation: 31
you could just put at the start of your backup script:
Code:
/path/to/mount/script mount
and at the end:
Code:
/path/to/mount/script unmount
and make a mount script like:
Code:
if [ "$1" = "mount" ]; then
mount /dev/<device> /mount/point -t ext3 -o rw
exit 0
elif [ "$1" = "unmount" ]; then
umount /mount/point
exit 0
else
exit 0
fi
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't mount hard drive. Alvis Linux - Hardware 4 07-25-2005 01:31 PM
how do you mount a hard drive? blackdragon Linux - Newbie 2 07-22-2005 10:28 AM
mount usb module then mount usb hard drive guanyu Linux - Hardware 1 10-08-2003 11:50 AM
can't mount new hard drive yanban Linux - Hardware 5 07-19-2003 05:09 AM
How to mount a hard drive ed1023 Linux - General 1 08-31-2002 10:04 PM


All times are GMT -5. The time now is 07:37 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