USB drive... /dev/sda1 doesn't show unless I try mounting /dev/sda as vfat
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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*
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.