1

I have four identical USB flash drives connected to a Raspberry Pi, one of which is (apparently) failing. I'm trying to find out which one..

It (the device is at /dev/sda) won't mount, with the following error:

mount: /dev/sda is write-protected, mounting read-only
mount: /dev/sda: can't read superblock

dmesg shows the following:

[3207772.134654] print_req_error: critical target error, dev sda, sector 0
[3207772.135995] sd 0:0:0:0: [sda] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[3207772.136010] sd 0:0:0:0: [sda] tag#0 Sense Key : 0x7 [current] 
[3207772.136021] sd 0:0:0:0: [sda] tag#0 ASC=0x27 ASCQ=0x0 
[3207772.136036] sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 00 00 00 f0 00 00 10 00
[3207772.136046] print_req_error: critical target error, dev sda, sector 240
[3207772.140555] sd 0:0:0:0: [sda] Write Protect is on
[3207772.140571] sd 0:0:0:0: [sda] Mode Sense: 23 00 80 00

I can't create a new file system on it because of the write protection, and running something like

hdparm -r0 /dev/sda

to manually turn off the write protection makes no difference, the device still won't do anything - it won't mount and it won't do anything.

This leads me to believe, after a lot of googling around, that the flash drive is faulty. My next step is to take it out and try if it'll mount on another system. So now my next problem is: which of the four drives is it? The drives are all identical and there's no led on the flash drives indicating anything..

lsusb tells me this:

# lsusb
Bus 001 Device 006: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 001 Device 004: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 001 Device 008: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 001 Device 007: ID 058f:6387 Alcor Micro Corp. Flash Drive

Not very useful... How can I identify which of the four drives it is?

Note 1: besides the obvious idea unmounting all of them, putting them back one by one and seeing which ones mount when of course :)

Note 2: I know that putting 4 USB flash drives in a Pi is not a good idea performance-wise because of the hub design - the project is more of a 'can it work' thing instead of a 'will it perform well' :)

Thanks in advance for the help and advice!

  • I feel you are not using the correct tools for the job. With all 4 USB devices plugged in, run lsblk --fs at the cmdline & let us know what that result is. Also, you may wish to read this for background – Seamus Feb 7 at 17:11
  • 1
    I don't think there are any right tools for the job here, if the issue is you need to identify which physical jack the drive is in. Built-in USB buses (of which the pi only has one) may have consistent numbers (probably because they are built in and always register in the same order), but the individual USB jacks do not. I think this is an aspect of the protocol: The bus/hub identifies devices plugged into it to the operating system, but it does not differentiate one physical jack from another. Put another way, there's no way to identify such a jack except by what is plugged into it. – goldilocks Feb 7 at 20:45
  • 1
    @goldilocks: By "right tools" I meant that a) he is trying to mount a device instead of a partition, and b) lsblk --fs will give a clearer picture of what's actually plugged into his system. I feel you're correct, but there may be a work-around - depending on the OPs objectives: basically that is to use labels for each USB drive. – Seamus Feb 7 at 20:57
  • Adding a device or fs UUID or label would be a good idea if it fits within the whole context, then physically mark each drive so you can correspond them. – goldilocks Feb 7 at 21:52
  • @goldilocks: I think so, too. I was going to suggest that the OP define labels that corresponded to the slot that it's plugged into; e.g. USB-ULH for Upper Left Hand USB slot, etc. Physical marking would help ensure they always go back into the same slot! – Seamus Feb 7 at 23:01
1

Use this command to obtain status on all block devices:

lsblk --fs  

You should get something that looks like this:

NAME FSTYPE LABEL UUID MOUNTPOINT
sda
└─sda1 exfat SANDISK16GB 5B00-9E5C /home/pi/mntThumbDrv
sdb
└─sdb1 vfat PASSPORT2TB F2EC-14F5 /home/pi/mntPassport
sdc
└─sdc1 vfat 809C-D7C7
mmcblk0
├─mmcblk0p1 vfat boot 5DB0-971B /boot
└─mmcblk0p2 ext4 rootfs 060b57a8-62bd-4d48-a471-0d28466d1fbb /

In this case:
* sda is a USB thumb drive with a single partition: sda1
* sdb is a USB WD "Passport" drive (i.e. spinning disk inside)
* sdc is a USB thumb drive with single partition, currently unmounted
* mmcblk0 is the SD card with boot and rootfs partitions

If you want to mount a drive (partition), it needs a file system. Create the filesystem using the appropriate version of mkfs (e.g. mkfs.fat to create a FAT file system). Read man mkfs.fat for detailed usage & options.

You will not be able to depend on the system to make the same device assignment at each boot. For example, the USB device plugged into the ULH (upper left hand) USB slot may be designated sda today, but sdc a week from now when you reboot. Also, they will not have a long, unique UUID (read references below for explanations for this). This leaves you with only one option for making your USB drives "unique": the LABEL id.

As discussed in the comments to your question, you could implement the following system to keep track of your USB devices:

  1. Physically mark each device (tape, marker, etc), and
  2. Designate a unique LABEL for each device when you create the filesystem using mkfs.XXX

Let us know how you get on after you've tried this. We'll try to help with any detailed follow-up questions you may have.

FURTHER READING:
* Differences between /dev/sda and /dev/sda1
* What does /dev/sda for linux mean?
* How To Partition and Format Storage Devices in Linux
* How To Connect an External Drive to Raspberry Pi?

  • This is not clear from my question, but I'm aware that I shouldn't mount devices directly. In my fstab I'm using the UUID's from blkid. Those UUID's are persistent across reboots and independent of the order in which the drives are either connected to the USB bus, or mounted on the system, correct? The step I should have done to identify failed drives is the physical labelling :). It didn't occur to me that I wouldn't be able to identify them. – pietervanwijngaarden Feb 8 at 8:59
  • UUIDs (for USB devices) aren't a good option for maintaining a unique handle for a particular drive. Using LABELs created using mkfs.XXXX is stable, and the LABEL can be used in your fstab. See the last reference above. – Seamus Feb 8 at 17:35
2

The correct answer, as far as I can see now, is that you cannot identify which physical USB port/jack a drive is connected to from the information in the Operating System alone.

The lsusb, blkid and lsblk tools will tell you which (block storage) devices are on the USB bus (and if they are mounted, which file system and mount point they have), but if you add multiple identical devices to the USB bus, your best bet is to connect and mount them one by one and label/mark them (physically, not in the OS) to differentiate them from each other.

And use the mount procedures that @Seamus provided, see answer above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.