LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-13-2006, 02:28 AM   #1
joreen
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Rep: Reputation: 0
USB Thumb drive mounting issues


Hi all,

I have a start up script that starts at runlevel 5, in which it's purpose is to detect a file in the thumb drive (path: /media/CANON_DC/file_xyz)

I have no problem in detecting the /media/CANON_DC directory. However, I cannot detect the file_xyz.

In my script, before I starting the read the content of file_xyz, I have done some echo so that I can know which part of the script is having a problem.
1. ls /proc/bus/usb -> I am able to see the USB thumb drive device in the file - devices
2. ls /media/CANON_DC -> no file exists
3. cat /proc/scsi/scsi -> no USB storage drive exists during the script is running.

However, when I run my script after GNOME is started, the script works perfectly.

May I know what is the problem here? Could it be the undetectable scsi during run level 5?
How can I read the content of file_xyz? Please advice! Thank You!

Last edited by joreen; 07-13-2006 at 02:31 AM.
 
Old 07-13-2006, 03:29 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
The most likely thing is that the drive hasn't yet been mounted. Removable storage drives such as USB drives, CDs and DVDs are usually mounted by the automounter. However, it is possible that your script is running before the automounter starts. Check to see the relative order of the automounter script (which on my FC5 system is called autofs) and your script.

Another possibility is that gnome may be doing something clever to mount the drive. Can you get your script to do issue a [tt]mount[/tt] command and capture the output so we can see whether the drive is actually mounted or not.

Are you detecting your file using ls by the way? If so, there's a better way; use the following code instead:

Code:
[ -f "/media/CANON_DC/file_xyz" ]
The [] indicate that it's a boolean test. This will return a 0 or 1. -f tells it to look for the existence of a file. You could then combine this with an if statement, thus:

Code:
if [ -f "/media/CANON_DC/file_xyz"] ; then
    echo "good, file exists"
else
    echo "bad, can't find file...HELP!"
fi
To detect a directory, use -d in place of -f.
 
Old 07-13-2006, 04:32 AM   #3
joreen
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Hi cdhgee

Thanks for your reply!
I think that my script must be running before the USB drive is mounted.
May I know how can I configure the automounter such that it can starts before my script at level 5?

These are output from the "mount" command:
/dev/md0 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
It looks like the USB is not mounted at the point of my script running.

Please advice on how I can do the mounting process right before my script.
Thank You!
 
Old 07-13-2006, 04:38 AM   #4
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Well there's various ways you could do it. Assuming you're running Fedora and as root, then this is one option, at the beginning of your script:

Code:
service autofs start
which would explicitly start the automounter.

Alternatively, manually mounting the drive is another option:

Code:
mount -t vfat /dev/sda1 /media/CANON_DC
Though that requires more effort as you then have to make sure that sda1 is the correct device and that the CANON_DC directory exists prior to mounting into it.

The most elegant solution would be to change the startup order of the scripts - this is controlled by a number in the header comment of your script. If you compare your script and /etc/init.d/autofs, you will see that autofs has a startup and a shutdown priority - simply adjust your script so that the startup priority is after that of autofs and all should be good.
 
  


Reply

Tags
autofs, disk, file, if, mount, removable, usb


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 8 01-16-2012 12:09 PM
USB thumb drive mounting as Read Only baryonyx SUSE / openSUSE 3 05-25-2006 12:57 AM
Mounting a thumb drive lucky6969b Linux - General 10 02-16-2006 10:52 PM
USB drive using different partitions (usb key thumb drive) Arodef Linux - Hardware 0 08-04-2004 06:36 PM
Mounting USB Thumb Drive Issues xm0b31 Linux - Hardware 2 04-27-2004 06:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:46 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration