I had an USB on a headless raspberry pi running debian, but after rebooting without unmounting (there were programs running on the mounted folder), I couldn't use the USB anymore. The following is the output on my Ubuntu 18.04 of:

lsusb, the drive is there:

Bus 001 Device 005: ID 090c:3000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)

ll /dev/disk/by-id/usb-Silicon_Motion_Inc._USB_MEMORY_BAR-0\:0, shows the link to /dev/sdb

/dev/disk/by-id/usb-Silicon_Motion_Inc._USB_MEMORY_BAR-0:0 -> ../../sdb

file /dev/sdb:

/dev/sdb: block special (8/16)

However, mount /dev/sdb folder shows:

mount: /home/steamos/TOSH: no medium found on /dev/sdb.

I found the following information that looks like the problem: blockdev --report /dev/sdb:

RO    RA   SSZ   BSZ   StartSec            Size   Device
rw   256   512  4096          0               0   /dev/sdb

and udevadm info -a -n /dev/sdb if can help:

looking at device '/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-7/1-7:1.0/host10/target10:0:0/10:0:0:0/block/sdb':
ATTR{inflight}=="       0        0"
ATTR{stat}=="       0        0        0        0        0        0        0        0        0        0        0"

So the problem is with device size and ATTR{stat}== 0 0 0 0....

dmesg -w shows:

[33490.303624] usb 1-7: USB disconnect, device number 5
[33510.836920] usb 1-7: new high-speed USB device number 6 using xhci_hcd
[33511.432630] usb 1-7: New USB device found, idVendor=090c, idProduct=3000
[33511.432634] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[33511.432636] usb 1-7: Product: SM3255AA MEMORY BAR 
[33511.432638] usb 1-7: Manufacturer: Silicon Motion,Inc. 
[33511.438206] usb-storage 1-7:1.0: USB Mass Storage device detected
[33511.438372] scsi host10: usb-storage 1-7:1.0
[33512.473781] scsi 10:0:0:0: Direct-Access              USB MEMORY BAR   1000 PQ: 0 ANSI: 0 CCS
[33512.474222] sd 10:0:0:0: Attached scsi generic sg2 type 0
[33512.474975] sd 10:0:0:0: [sdb] Attached SCSI removable disk

How can I recover the files on the USB?


How can I recover the files on the USB?

Even though I hope that you will be able to fully save the drive, I would like to answer this question.

1. Create an image of the drive

This is a pretty important step that will prevent you from doing even more damage than good. This is a good idea even before you proceed to try and fix the drive. The file recovery we will do later will be performed on the disk image, instead of the real disk. To create a disk image, simply issue the following command: (Status flag is optional, it shows the progress statistic as dd is running)

$ sudo dd if=/dev/sdb of=sdb.img bs=1M status=progress

2. Perform file recovery

There are plenty of recovery applications, personally I find that photorec and foremost work best. photorec is usually part of the testdisk package. On debian, you can install both as followed:

$ sudo apt-get install testdisk foremost

a) Photorec

Simply run $ photorec sdb.img now to open up photorec's interactive interface.

Hit return ([Proceed]) to select the disk image. In the next screen, you're asked to select a partition. If photorec finds the correct partitions, you can select the one you want to recover the files from here. If it doesn't detect the partitions properly, simply select No partition [Whole disk] and hit return again to perform the [Search]. Once selected the filesystem type in the next screen, you need to select a directory in which the recovered files should be saved. Confirm with C.

Once it's done, proceed with step 3.

b) Foremost

While photorec works by trying to find "data blocks" of the drive and media within using file carving, foremost does it a bit differently. It's still using the file carving concept but it ignores the type of underlying filesystem and directly works by copying segments of the drive into your RAM, which is then being scanned for file header types. Foremost comes with a lot of built-in headers to recover most types of common files, if you want to add custom headers/footers to detect less common file types, foremost offers you this ability.

To run foremost using the default options on the image, run the following command:

$ foremost -i sdb.img -v

That will save all recovered files into output (new directory that foremost will create). You can specify another output directory using the -o flag, and -a to ignore errors/save corrupted files.

3. Filter the recovered files

This is optional, but sometimes you are only interested in specific types of files, or even worse: Recovery tools give you a million of files out of which thousands appear to be, for example, a JPEG file, but in reality it's just a corrupted file and not a picture at all. To filter these out you can use this answer I gave to another question on SuperUser.

  • I had the same idea of taking a snapshot of the usb, but unfortunately, this is the output dd: failed to open '/dev/sdb': No medium found. – tty11 Jul 30 '18 at 18:42
  • What happens if you try dd if=/dev/disk/by-id/usb-Silicon_Motion_Inc._USB_MEMORY_BAR-0\:0 of=sdb.img bs=1M ? – confetti Jul 30 '18 at 18:52
  • Same thing, dd: failed to open '/dev/disk/by-id/usb-Silicon_Motion_Inc._USB_MEMORY_BAR-0:0': No medium found. – tty11 Jul 30 '18 at 18:53
  • Does fdisk -l detect the disk at all? If not: Unplug the drive, run dmesg -w and plug it back in. Update your OP to add the relevant lines please. – confetti Jul 30 '18 at 18:56
  • Updated, and no fdisk -l doesn't detect it. That's the thing. – tty11 Jul 30 '18 at 19:11

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.