Help writing script file to mount / mount hard drive
Linux - GeneralThis 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
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.
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.