LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cannot read/write SD card after improper format (sector size 0) (https://www.linuxquestions.org/questions/linux-general-1/cannot-read-write-sd-card-after-improper-format-sector-size-0-a-885873/)

hedpe 06-12-2011 05:10 AM

cannot read/write SD card after improper format (sector size 0)
 
Hi all,

I was attempting to reformat a 16GB MicroSD card in my camera when the battery died mid-way. After that, any time I try to read the card in my camera, it gives me a "Card Error" and does not allow me to reformat it in my camera.

So, I thought I would plug the camera in to the laptop with it set to host the card as media when plugged in as USB, in an attempt to fix the formatting issue.

However, when I plug it in to my linux machine, it does not register as a device (e.g., /dev/sda) due to some errors, therefore I cannot reformat it. Essentially, I think I need to fix the partition table but I'm not sure how to when it doesn't register as a device.

Code:

[17179738.056000] usb 5-1: new high speed USB device using ehci_hcd and address 3
[17179738.188000] usb 5-1: configuration #1 chosen from 2 choices
[17179738.540000] usbcore: registered new driver libusual
[17179738.636000] Initializing USB Mass Storage driver...
[17179738.636000] scsi0 : SCSI emulation for USB Mass Storage devices
[17179738.636000] usb-storage: device found at 3
[17179738.636000] usb-storage: waiting for device to settle before scanning
[17179738.636000] usbcore: registered new driver usb-storage
[17179738.636000] USB Mass Storage support registered.
[17179743.636000] usb-storage: device scan complete
[17179743.636000]  Vendor: CASIO    Model: DIGITAL_CAMERA    Rev: 1.00
[17179743.636000]  Type:  Direct-Access                      ANSI SCSI revision: 00
[17179743.768000] sda : very big device. try to use READ CAPACITY(16).
[17179743.768000] sda : READ CAPACITY(16) failed.
[17179743.768000] sda : status=0, message=00, host=5, driver=00
[17179743.768000] sda : use 0xffffffff as device size
[17179743.768000] sda : sector size 0 reported, assuming 512.
[17179743.768000] SCSI device sda: 4294967296 512-byte hdwr sectors (2199023 MB)
[17179743.772000] sda: Write Protect is off
[17179743.772000] sda: Mode Sense: 00 46 00 00
[17179743.772000] sda: assuming drive cache: write through
[17179743.776000] sda : very big device. try to use READ CAPACITY(16).
[17179743.780000] sda : READ CAPACITY(16) failed.
[17179743.780000] sda : status=0, message=00, host=5, driver=00
[17179743.780000] sda : use 0xffffffff as device size
[17179743.780000] sda : sector size 0 reported, assuming 512.
[17179743.780000] SCSI device sda: 4294967296 512-byte hdwr sectors (2199023 MB)
[17179743.780000] sda: Write Protect is off
[17179743.780000] sda: Mode Sense: 00 46 00 00
[17179743.780000] sda: assuming drive cache: write through
[17179743.780000]  sda:<6>usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179804.292000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179834.696000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179865.096000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179895.500000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179925.900000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179926.188000] sd 0:0:0:0: SCSI error: return code = 0x50000
[17179926.188000] end_request: I/O error, dev sda, sector 0
[17179926.188000] Buffer I/O error on device sda, logical block 0
[17179956.300000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17179986.704000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17180017.104000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17180047.508000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17180077.908000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17180108.312000] usb 5-1: reset high speed USB device using ehci_hcd and address 3
[17180108.600000] sd 0:0:0:0: SCSI error: return code = 0x50000
[17180108.600000] end_request: I/O error, dev sda, sector 0
[17180108.600000] Buffer I/O error on device sda, logical block 0
[17180108.600000]  unable to read partition table

Does anyone have any ideas of what I could do, here? I have another card of the exact brand and size, so I could get the number of sectors from it.

business_kid 06-12-2011 09:22 AM

If you can't mount it, the trick would be to copy the other one same size in it's entirety for safety with dd

dd if=good_drive of=bad_drive && sync might just do it. There could be a tmp file if you have 16 gigs of space somewhere.

hedpe 06-12-2011 05:20 PM

Quote:

Originally Posted by business_kid (Post 4383378)
If you can't mount it, the trick would be to copy the other one same size in it's entirety for safety with dd

dd if=good_drive of=bad_drive && sync might just do it. There could be a tmp file if you have 16 gigs of space somewhere.

Hmmmm I'm notmsure how to use dd in this case when it doesn't settle and register to /dev/sda. It doesn't show up in fdisk

business_kid 06-13-2011 03:01 AM

Quote:

Originally Posted by hedpe (Post 4383635)
Hmmmm I'm notmsure how to use dd in this case when it doesn't settle and register to /dev/sda. It doesn't show up in fdisk

The drive was registered, but unmountable, right? So your partition table etc is garbage.If you can let the computer see the 2 (good=sda, bad=sdb), use
dd if=/dev/sda of=/dev/sdb

That should write from sda to sdb. That gets partition table, boot sectors, data, & free space.
A 16G write will go on at 12MB/S and will take a _long_time, as it will be reading then writing.
You could try with a meg first(in fact 32G@12MB/S)

dd if=/dev/sda of=/dev/sdb bs=1M count=1
fdisk /dev/sdb

and you might be lucky. Please post the result, as these forums are searched.

hedpe 06-13-2011 03:36 AM

Quote:

Originally Posted by business_kid (Post 4383900)
The drive was registered, but unmountable, right? So your partition table etc is garbage.If you can let the computer see the 2 (good=sda, bad=sdb), use
dd if=/dev/sda of=/dev/sdb

That should write from sda to sdb. That gets partition table, boot sectors, data, & free space.
A 16G write will go on at 12MB/S and will take a _long_time, as it will be reading then writing.
You could try with a meg first(in fact 32G@12MB/S)

dd if=/dev/sda of=/dev/sdb bs=1M count=1
fdisk /dev/sdb

and you might be lucky. Please post the result, as these forums are searched.

unfortunately it never registers to /dev/sda :\ so i am not sure how to dd in this case

MTK358 06-13-2011 08:31 AM

Why not repartition the bad drive?

Code:

cfdisk ???
Replace "???" with the path to your USB drive. If you're not sure what it is, try this:

Code:

#!/bin/bash
drives="$(ls -1 /dev/sd?)"
echo -n  "Plug in your USB drive and press Enter"
read
sleep 5s
drives="${drives}
$(ls -1 /dev/sd?)"
echo "$drives" | uniq -u

Save it in a file, and run it like this:

Code:

bash name-of-file-containing-above-script

hedpe 06-13-2011 11:46 AM

Quote:

Originally Posted by MTK358 (Post 4384165)
Why not repartition the bad drive?

Code:

cfdisk ???
Replace "???" with the path to your USB drive. If you're not sure what it is, try this:

Code:

#!/bin/bash
drives="$(ls -1 /dev/sd?)"
echo -n  "Plug in your USB drive and press Enter"
read
sleep 5s
drives="${drives}
$(ls -1 /dev/sd?)"
echo "$drives" | uniq -u

Save it in a file, and run it like this:

Code:

bash name-of-file-containing-above-script

Unfortunately this also won't work because it never gets to the point of registering as a device. So it registers nothing in /dev.

business_kid 06-14-2011 04:02 AM

OK, Give up. Let me refer you to rule 2 in the main rules of servicing.

1. If it works, don't fix it.
2. If it's not worth it, don't fix it.

I don't know whether you broke 1 as well, but if there's no way back, there's no way back. And that's what it sounds like.

Last thing worth a shot might be testdisk. Either it finds it or it doesn't. If it doesn't, give up.You're throwing time after money at this stage.


All times are GMT -5. The time now is 10:55 AM.