LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 02-10-2006, 01:52 AM   #1
finite
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: Arch Linux 0.7.2
Posts: 8

Rep: Reputation: 0
USB drive... /dev/sda1 doesn't show unless I try mounting /dev/sda as vfat


I'm using a Kingmax USB 2.0 thumbdrive. Kernel 2.6.10, Slackware Current.

When I plug it in, /dev/sda appears in my filesystem, but /dev/sda1 doesn't show. It seems that the driver isn't able to get access to the partition table on its first try. Here's the dmesg output:

Code:
hub 3-0:1.0: state 5 ports 6 chg ffc0 evt 0002
ehci_hcd 0000:00:07.3: GetStatus port 1 status 001803 POWER sig=j  CSC CONNECT
hub 3-0:1.0: port 1, status 0501, change 0001, 480 Mb/s
hub 3-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x501
ehci_hcd 0000:00:07.3: port 1 high speed
ehci_hcd 0000:00:07.3: GetStatus port 1 status 001005 POWER sig=se0  PE CONNECT
usb 3-1: new high speed USB device using ehci_hcd and address 15
ehci_hcd 0000:00:07.3: port 1 high speed
ehci_hcd 0000:00:07.3: GetStatus port 1 status 001005 POWER sig=se0  PE CONNECT
usb 3-1: new device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-1: default language 0x0409
usb 3-1: Product: Flash Disk
usb 3-1: Manufacturer: USB
usb 3-1: SerialNumber: 94A343A62124002E
usb 3-1: hotplug
usb 3-1: adding 3-1:1.0 (config #1, interface 0)
usb 3-1:1.0: hotplug
usb-storage 3-1:1.0: usb_probe_interface
usb-storage 3-1:1.0: usb_probe_interface - got id
scsi9 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 15
usb-storage: waiting for device to settle before scanning
  Vendor: KINGMAX   Model: USB Flash Disk    Rev: 2.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
sda: Unit Not Ready, sense:
Current : sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda : READ CAPACITY failed.
sda : status=1, message=00, host=0, driver=08
Current sd: sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda: assuming Write Enabled
sda: assuming drive cache: write through
sda: Unit Not Ready, sense:
Current : sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda : READ CAPACITY failed.
sda : status=1, message=00, host=0, driver=08
Current sd: sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda: assuming Write Enabled
sda: assuming drive cache: write through
sda: Unit Not Ready, sense:
Current : sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda : READ CAPACITY failed.
sda : status=1, message=00, host=0, driver=08
Current sd: sense = 70  6
ASC=28 ASCQ= 0
Raw sense data:0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x28 0x00 0x00 0x00 0x00 0x00
sda: assuming Write Enabled
sda: assuming drive cache: write through
 sda:end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
Buffer I/O error on device sda, logical block 0
 unable to read partition table
Attached scsi removable disk sda at scsi9, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi9, channel 0, id 0, lun 0,  type 0
usb-storage: device scan complete
However, if I try to mount /dev/sda as VFAT:

Code:
mount /dev/sda /mnt/usb -t vfat
... it fails (obviously), yet after this sda1 becomes visible and I can mount the device just fine. It seems that doing this forces the driver to rescan the USB drive, and it finds the partition. This appears in dmesg immediately after the failed mount attempt:

Code:
sda: assuming Write Enabled
sda: assuming drive cache: write through
SCSI device sda: 1017856 512-byte hdwr sectors (521 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
 sda: sda1
FAT: invalid media value (0x01)
VFS: Can't find a valid FAT filesystem on dev sda.
After this, I can mount the device just fine, by doing:

Code:
mount /dev/sda1 /mnt/usb -t vfat
Now, I can certainly put both commands in a quick bash script, and that would mount the device, but it seems to me that /dev/sda1 should appear during the initial scans. Is there any way to make the USB driver try a few more times to read the partition table before giving up?

Any ideas?
 
Old 02-10-2006, 03:23 AM   #2
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
Welcome to LQ!

Ideas, yes. I had the same type of issue with a USB 2.0 flash drive, but it wasn't exactly like yours. I put those guys in /etc/fstab and always had the correct command, but a lot of times it wouldn't find it just as your output in the first example. The problem with mine was the formatting of the flash disk. I reformatted it FAT32 from within Slackware, and it always works now. Try these two things.

First, put it in /etc/fstab as such:
Code:
/dev/sda1        /mnt/usb         vfat        noauto,users,rw,umask=1000  0  0
That allows you to mount it as a user, not root, and not give the filesystem. So issue "mount /mnt/usb" and you're done.

Second, reformat it from command line with this command:
Code:
/sbin/mkdosfs -F32 -v /dev/sda1
You format the drive without it mounted. After that, pull it out, then put it back in and see what "dmesg | tail" shows after it scans it ... maybe 10 - 30 seconds depending upon your comp. And then issue "/sbin/fdisk -l" to see what it shows up as in there.

The other thing you might need to do is run "cfdisk /dev/sda" and erase the old partition table and write a new one. If so, the type for the FAT32 filesystem is 0C.
 
Old 02-10-2006, 04:39 AM   #3
finite
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: Arch Linux 0.7.2
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for the ideas. I gave that all a try, even repartitioned and reformatted the drive, but it still doesn't show up as /dev/sda1 by itself. Although I've found now that after I've run fdisk -l (which shows the partitions just fine), /dev/sda1 magically appears. I guess the USB drive just needs more time to initialise after receiving power than the drivers allow it.

Well, as a temporary solution I just made this alias:
Code:
alias usb='mount /dev/sda 2> /dev/null; mount -v /mnt/usb'
(/dev/sda is just mounted to /dev/null in my fstab, as it fails anyway. Piped the error output to null to clean it up )

It's a strange hack, but afaik mount is the only user level command that makes it reread the partition table. In any case, it works just fine for now. Just would be nice if it wasn't necessary.
 
Old 02-10-2006, 06:09 AM   #4
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
If I'm following you, are you just not waiting long enough for it to scan?

Could you unplug it, then plug it in and wait a while, then post the "dmesg | tail" output?
 
Old 02-10-2006, 08:52 AM   #5
cferron
Member
 
Registered: Jan 2006
Location: Trois-Rivières, Québec, Canada
Distribution: Slackware, Ubuntu
Posts: 74

Rep: Reputation: 15
Post Same issue with compact flash card

I have the same issue with a flash card reader. Even when a card is inserted I had to 1- mount /sda and get an error in order to have sda1 appear... My solution was to add the following in the rc.local:

mknod /dev/sda1 b 8 1

and this in my fstab:

/dev/sda1 /mnt/reader vfat noauto,users,rw 0 0

It seem that hotplug is not creating the entry in /dev . Maybe because when a card is inserted the system is "passive" it does not detect that you have insert a card in the reader, therefore the reason why you have to mount 1 time so the system say: OH! there is a card now in the reader... let's create /dev/sda1 and then able to acces the card.

My solution bypass this issue, I can now mount without having an error since I create /dev/sda1 when the system is started. I still have issue however with the fact that I need to mount and unmount flash card a lot on my system (about 10-15 time an hour) and this has for effect that /sda DISSAPEAR and the device is no more accessible.

Maybe some could help on this issue? See post:
http://www.linuxquestions.org/questi...d.php?t=272359


Hope this help somehow.

Claude
 
Old 02-10-2006, 08:14 PM   #6
finite
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: Arch Linux 0.7.2
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Chinaman
If I'm following you, are you just not waiting long enough for it to scan?

Could you unplug it, then plug it in and wait a while, then post the "dmesg | tail" output?
I've done that, waited for several minutes, and /dev/sda1 never appears unless I take some action.

Quote:
Originally Posted by cferron
I have the same issue with a flash card reader. Even when a card is inserted I had to 1- mount /sda and get an error in order to have sda1 appear... My solution was to add the following in the rc.local:

mknod /dev/sda1 b 8 1
I actually gave that a try earlier on, but as you said if you remove the device and reconnect it, the /dev/sda1 entry disappear (presumably because hotplug detected that /dev/sda was gone). So you'd have to keep running mknod whenever it vanishes. *shrug*
 
Old 02-10-2006, 08:50 PM   #7
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Just run 'hdparm -z /dev/sda' to tell the kernel to rescan the partition table. I suggest setting up sudo to run this command to run it as a normal user.

Adding a line in /etc/fstab for USB storage devices is not smart because USB storage devices changes their device nodes over time if usb-storage and sd_mod is not removed. Though if you still want to place a line in /etc/fstab for USB storage devices, include only the label of the device that was set during formating the partition.
 
Old 06-05-2006, 12:20 PM   #8
DarkstarNZ
LQ Newbie
 
Registered: Jun 2006
Location: Wellington, New Zealand
Distribution: Slackware
Posts: 7

Rep: Reputation: 0
Simplest advice always the best

Quote:
Originally Posted by Electro
Just run 'hdparm -z /dev/sda' to tell the kernel to rescan the partition table. I suggest setting up sudo to run this command to run it as a normal user.

Adding a line in /etc/fstab for USB storage devices is not smart because USB storage devices changes their device nodes over time if usb-storage and sd_mod is not removed. Though if you still want to place a line in /etc/fstab for USB storage devices, include only the label of the device that was set during formating the partition.
Running the 2.6.16.15.kernel on slackware with the dropline GUI, I was really tussling with the USB flash drive and portable USB HDD until I read this.

When I changed kernels, I never thought to update the entries in the old fstab file that I needed when the HALD was not on board.

Grrrrrrrrrr

Cheers for the (obvious but) very useful tip!
 
Old 03-10-2009, 12:52 AM   #9
ankita.dutta
LQ Newbie
 
Registered: Mar 2009
Posts: 7

Rep: Reputation: 0
I want to write a software that will be able to access USB drive. Can anyone help me please?
 
  


Reply


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
USB pen drive not mounting. /dev/sda1 not present! hamish Linux - Hardware 9 01-11-2010 08:25 PM
no /dev/sda or sda1 RoaCh Of DisCor Slackware 28 02-12-2006 11:10 AM
USB drive... /dev/sda1 does not exist! Lord Zoltar Linux - Hardware 48 05-15-2005 11:55 AM
/dev/sda and /dev/sda1 disappeared using sii3112A striderstrahan Linux - Software 0 09-16-2004 05:00 AM
USB Compact flash card reader hotplug creates /dev/sda but no /dev/sda1 -Mandrake 9.1 bibinono Linux - Hardware 2 08-11-2003 09:37 AM


All times are GMT -5. The time now is 05:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration