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 |
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.
|
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.
|
Thats what I would like some help on. Would it just be a simple mount and unmount in the script file?
|
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 |
you could just put at the start of your backup script:
Code:
/path/to/mount/script mount Code:
/path/to/mount/script unmount Code:
if [ "$1" = "mount" ]; then |
All times are GMT -5. The time now is 08:45 PM. |