LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-12-2011, 05:10 AM   #1
hedpe
Member
 
Registered: Jan 2005
Location: Pittsburgh
Distribution: Ubuntu
Posts: 378

Rep: Reputation: 30
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.
 
Old 06-12-2011, 09:22 AM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,309

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
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.
 
Old 06-12-2011, 05:20 PM   #3
hedpe
Member
 
Registered: Jan 2005
Location: Pittsburgh
Distribution: Ubuntu
Posts: 378

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by business_kid View Post
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
 
Old 06-13-2011, 03:01 AM   #4
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,309

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
Quote:
Originally Posted by hedpe View Post
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.
 
Old 06-13-2011, 03:36 AM   #5
hedpe
Member
 
Registered: Jan 2005
Location: Pittsburgh
Distribution: Ubuntu
Posts: 378

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by business_kid View Post
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
 
Old 06-13-2011, 08:31 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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
 
Old 06-13-2011, 11:46 AM   #7
hedpe
Member
 
Registered: Jan 2005
Location: Pittsburgh
Distribution: Ubuntu
Posts: 378

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 06-14-2011, 04:02 AM   #8
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,309

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to format a SD card that's recognized as a read-only file? darthpinguim Linux - Hardware 4 02-26-2011 10:57 PM
Program to read total read/write cycles for compact flash card timetraveler Linux - Hardware 0 05-06-2010 09:49 PM
How can I read and write in ASCII format grib files? iandroul Linux - Software 1 07-14-2008 09:19 AM
Improper module format error for Orinoco driver relpats_eht Slackware 1 03-26-2005 11:04 AM
read the input file and write in the given format suchi_s Programming 8 12-17-2004 01:12 AM


All times are GMT -5. The time now is 06:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration