USB Thumb drive mounting issues
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!
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:
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.
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:
Alternatively, manually mounting the drive is another option:
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.
|All times are GMT -5. The time now is 03:09 PM.|