1

OK, I don't know what's going on here, at first I thought it was a problem I remember having some time ago where I couldn't mount a vfat partition because it had some flag set that it had not been cleanly removed. I remember there was a way to fix this, but I can't find it now. In any case, I don't think that is the problem here, and I've been searching for a few days with no luck.

This is an SDHC card (32GB) which I use for one of my cameras (I have another 32GB card I used for another camera, with the same USB adapter, and that works fine in linux) so I can see the files from within the camera no problem, but when I plug the adapter + card in linux, I get no device appearing in Konqueror. So I try to do:

# mount /dev/sdd /d/try/2
mount: you must specify the filesystem type
# mount -t vfat /dev/sdd /media/sdcard
mount: wrong fs type, bad option, bad superblock on /dev/sdd,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

fdisk says

fdisk -l /dev/sdd

Disk /dev/sdd: 31.9 GB, 31914983424 bytes
255 heads, 63 sectors/track, 3880 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            8192    62333951    31162880    c  W95 FAT32 (LBA)

but

# ls /dev/sdd*
/dev/sdd

So there's no /dev/sddX devices listed, though fdisk says they exist! gparted shows me the /dev/sdd1 partition no problem (but there's 4MB of free space before it). So this is where I suspect there is something different going on. Is it possible this free space is causing the problems? Why would it? Would resizing the partition to use up that 4mb (how did that even happen, though?) fix all this? And would this then cause the data to somehow now not be readable from the camera? Or worse, irretrievably corrupted? I'm pretty sure I have been able to access this card before from within linux since I think I even moved some files around (it has some photos from the other camera). So it's strange that I can't access it now.

Basically, I would like to know how to fix this (as non-destructively as possible), and what is causing the problem (to avoid it in the future). For reference I have included dmesg output.

# dmesg|tail -30
[3783978.490032] usb 1-5: new high-speed USB device number 44 using ehci_hcd
[3783978.608523] usb 1-5: New USB device found, idVendor=05e3, idProduct=0727
[3783978.608528] usb 1-5: New USB device strings: Mfr=3, Product=4, SerialNumber=2
[3783978.608530] usb 1-5: Product: USB Storage
[3783978.608531] usb 1-5: Manufacturer: Generic
[3783978.608533] usb 1-5: SerialNumber: 000000000207
[3783978.609406] scsi29 : usb-storage 1-5:1.0
[3783979.610445] scsi 29:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0207 PQ: 0 ANSI: 0
[3783979.613096] sd 29:0:0:0: Attached scsi generic sg3 type 0
[3783979.773160] sd 29:0:0:0: [sdd] 62333952 512-byte logical blocks: (31.9 GB/29.7 GiB)
[3783979.774295] sd 29:0:0:0: [sdd] Write Protect is off
[3783979.774300] sd 29:0:0:0: [sdd] Mode Sense: 0b 00 00 08
[3783979.775406] sd 29:0:0:0: [sdd] No Caching mode page present
[3783979.775410] sd 29:0:0:0: [sdd] Assuming drive cache: write through
[3783979.779038] sd 29:0:0:0: [sdd] No Caching mode page present
[3783979.779048] sd 29:0:0:0: [sdd] Assuming drive cache: write through
[3783981.471143] sd 29:0:0:0: [sdd] Unhandled sense code
[3783981.471147] sd 29:0:0:0: [sdd]  Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[3783981.471150] sd 29:0:0:0: [sdd]  Sense Key : Medium Error [current] 
[3783981.471153] sd 29:0:0:0: [sdd]  Add. Sense: Data phase CRC error detected
[3783981.471157] sd 29:0:0:0: [sdd] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
[3783981.471162] end_request: I/O error, dev sdd, sector 0
[3783981.471166] Buffer I/O error on device sdd, logical block 0
[3783981.482542] Dev sdd: unable to read RDB block 0
[3783981.482548]  sdd: unable to read partition table
[3783981.486264] sd 29:0:0:0: [sdd] No Caching mode page present
[3783981.486267] sd 29:0:0:0: [sdd] Assuming drive cache: write through
[3783981.486269] sd 29:0:0:0: [sdd] Attached SCSI removable disk
  • Did you forget to umount it the previous time, seeing how it used to be sdc and now it's sdd? Try reinserting it, there's no sdd1 as the kernel failed to read the partition table due to an error. – wurtel Apr 23 '15 at 7:21
  • Tried mounting /dev/sdd1 instead of sdd? – dhag Apr 23 '15 at 13:06
  • @wurtel, even while writing the question above, I did reinsert at least 2 more times, that didn't fix the problem. I'm not sure what happened with the /dev/sdc entry, no idea. I will try a few things and report back. – insaner Apr 23 '15 at 19:52
  • @dhag, yes, I did, but it just says mount: special device /dev/sdd1 does not exist – insaner Apr 23 '15 at 19:53
  • @wurtel, I didn't realize it, but the sdc errors were actually from a different device, I have removed them from the question. – insaner Apr 23 '15 at 20:04
1

Some advances, (I will edit this answer if/when I find a proper final solution). After doing a full backup of the device using @INDIVIDUAL-IT's dd command (I think using a bs=1M made the transfer painfully slow though). I was not able to mount the backup file, but a

# dd if=backup.img of=backup-skip.img bs=1M skip=4

did create a mountable file (backup-skip.img), and as far as I could tell all the files were there, and accessible. (UPDATE: writing this stripped image back to the SD card caused it to be automatically detected and mountable by linux, but non-working in the camera.)

I loaded up gparted again, and tried to remove that 4MB of empty space preceding my partition, but it was not possible, it did not allow me to get the partition to use up all the space, leaving a minimum of 1MB with no way to remove that (tried all the options for align, but no dice).

Out of curiosity, I unchecked the lba option of the sdd1 partition. I wasn't asked to confirm this change, nor did I click anywhere to commit the changes to the device either, but I saw the LED on the adapter flashing, and suddenly there was an entry in konqueror for my SD card. I unmounted, unplugged the USB device, and then plugged it back in, but the SD card was not autodetected, and I was back to square one. gparted on the device now tells me that lba is not activated on this device. Strange.

Partition detected!

The fog lifted a little from my memory thanks to the strange gparted effect, and so I ran:

# partprobe

and suddenly /dev/sdd1 is created, and the device appears in konqueror! So, not a final solution yet (since you have to run partprobe, as root, every time), but at least I can access my files. Hope that helps someone out there while I figure out a permanent fix.

0

For me it looks like your partition table is somehow messed up.

  1. make a complete backup of the card with dd: dd if=/dev/sdd of=backup.img bs=1M . If dd fails to copy the sd-card, then it is most likely hardware broken. You still can try your luck with ddrescue
  2. use TestDisk to try to recover the partition table. Do the recovery on the backup.img file, or even a backup of the backup-file. Just to be sure you are not making it worse.
  3. To get rid of the first 4MB use dd if=backup.img of=backup_striped bs=1M skip=4
  4. if the recovery gives you a mountable file with all files in there and fsck does not give you any error when testing you can write that recovered file back to the SD card. dd if=backup_striped of=/dev/sdd bs=1M make sure you are writing to the correct drive
  5. if the recovery of the partition fails you can user TestDisk to recover the files one by one with foremost or scalpel

You can user TestDisk to

  • I'm going to try out your new step #4 then. I have a feeling the bs=1M is making this really slow though. I just tried using testdisk, but it's kind of convoluted to figure out, and therefore be confident that I won't make things worse. – insaner Apr 24 '15 at 4:44
  • by the way, you wrote if= twice for your step 4. – insaner Apr 24 '15 at 4:45
  • thank you. I've changed the step 4. bs=1M is not critical you can try an other block size or just leave it all together – INDIVIDUAL-IT Apr 24 '15 at 6:23
  • dd if=backup_striped of=/dev/sdd rendered an SD card that is automatically detected and mountable by linux, but that does not work with the camera (and also took 11 hours! to write the image) – insaner Apr 25 '15 at 0:05
  • reformat the card in the camera. What partition table do you get? doe your camera maybe does some strange things with the card? P.S. dd with bs=1M might have been faster – INDIVIDUAL-IT Apr 25 '15 at 10:25
0

According to the logs, the kernel is getting an error from the hardware when it tries to read the partition table immediately after detecting the card. Yet, when you call partprobe later, the kernel is able to read the partition table just fine. It looks like there is either a hardware error or a driver bug that causes the initial read to fail. It could be that the SD card or reader firmware needs some time to finish initializing and the driver attempts to read too early. The solution (short of changing the hardware) would be to introduce a delay in the driver.

As a workaround, you can add a udev rule that matches your device and runs a script

#!/bin/sh
sleep 1
partprobe "$DEVNAME"

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.