Detect USB Drive and Execute the Command

Detect USB Drive and Execute the Command

am 24.09.2007 10:05:28 von gurdyal

Hello,
I am trying to write a shell script which will install image residing
on the USB drive onto Hard Drive.

When i boot computer, the hard drive is shown as /dev/sda and usb
drive as /dev/sdb

Below is the script i am trying to execute

mount /dev/sdb1 /usbdrive

echo Creating partitions
sfdisk --force /dev/sda < /usbdrive/img/TM090001.PAR
echo Installing Image
gzip -d -c /usbdrive/img/TM090001 - | dd bs=2M of=/dev/sda1

echo Installing MBR
dd if=/usbdrive/img/TM090001.MBR of=/dev/sda
echo done

The sript above has name InstallOS.sh and resides in USB drive /
commands/InstallOS.sh


But problem is when i have multipule usb drives, i won't know which
drive to mount

I want to have script :

which auto mounts the correct usb drive which has /img/*.MBR as /
usbdrive
copies /usbdrive/commands/InstallOS.sh to /work/
and executes /work/InstallOS.sh

any help will be appriciated

Regards,
Guru

Re: Detect USB Drive and Execute the Command

am 24.09.2007 16:04:53 von Bill Marcum

On Mon, 24 Sep 2007 01:05:28 -0700, gurdyal@gmail.com
wrote:
>
> But problem is when i have multipule usb drives, i won't know which
> drive to mount
>
> I want to have script :
>
> which auto mounts the correct usb drive which has /img/*.MBR as /
> usbdrive
> copies /usbdrive/commands/InstallOS.sh to /work/
> and executes /work/InstallOS.sh
>
> any help will be appriciated
>
> Regards,
> Guru
>
The solution to this is probably specific to what flavor of Unix or
Unix-like operating system you have. For example, in Linux you could
write rules in the /etc/udev directory to identify a drive by its
label or UUID and run a script when a particular drive is plugged in.


--
Elwood: What kind of music do you get here ma'am?
Barmaid: Why, we get both kinds of music, Country and Western.