Register
It is currently Wed Aug 20, 2014 4:24 pm

mount and umount drive


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue May 19, 2009 7:54 am   

Joined: Tue May 19, 2009 7:49 am
Posts: 1
I have been using udev for f8 and I need a script that mounts external usb, firewire drives and esata drives and increments the number cause more than 1 drive will be attached to the server.

I have at present been able to mount and unmount firewire drive but not sure how i increment the mount number. Also I have various servers and it should search the network to see automatically that a new drive is attached when a simple mount command is typed no user interaction.

any ideas will be great.

currently i have
# Mount drive on udev 'ACTION==add'
mkdir -p "/mnt/drive"$a
mount /dev/sda1 /mnt/drive
echo "Your drive is now mounted have fun!!"
and
unmount in another script i have
#!/bin/bash
# Unmount drive on udev 'ACTION==remove'
umount /mnt/drive

works well but too simple for what i want it too do.
many thanks


Top
 Profile  
 PostPosted: Sun Jun 21, 2009 3:57 am   

Joined: Sun Jun 21, 2009 3:23 am
Posts: 4
Quote:
I have at present been able to mount and unmount firewire drive but not sure how i increment the mount number

Your script needs to count how many mounted drives there are first and then +1 using expr/bc. Here is an example of what I mean. In my test directory I have created a.txt and b.txt, so there are 2 .txt files. I'm using expr to add 1 and outputting what the result would be:

Code:
#!/bin/bash

count=`ls *.txt | wc -l`
number=`expr $count + 1`
echo "Count: $count"
echo "Incrementing that would be: $number"


-twantrd


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP