Husar
Posts: 67
Joined: Tue Nov 12, 2013 12:43 am
Location: Midwest, USA
Contact: Website

Corrupt SD. Can I recover files?

Tue Dec 06, 2016 2:35 am

I have a corrupt SD card that I would like to recover some files off the desktop. The system load about halfway then I get the corrupt messages. The is on a RPi 2 vB if that makes any difference.

I am able to see the sd if I insert it into the Mac Book Pro. I have a boot0 and RECOVERY device that shows up when the card is inserted.

I don't have access to a windows machine. I have installed VirtualBox with Ubuntu hoping that that would help but I can't figure out how to mount the sd card in Ubuntu.

Any help would be very much appreciated to review files from the sd or get it booking again.

Thank you,
Ed
Ed

wh7qq
Posts: 1448
Joined: Thu Oct 09, 2014 2:50 am

Re: Corrupt SD. Can I recover files?

Tue Dec 06, 2016 3:07 am

The easiest approach I know is to set up an entirely new sd card...don't use the old one...load the OS and then use a USB card reader to see the files on the old sd card. You may not be able to open the boot partition but files that were saved on the old root partition may be recoverable. You can then copy them to the new sd card root partition. You might even get lucky and be able to recover your files from the boot partition but check them carefully before you use any of the old config files...they might be corrupted.

For future reference, be certain the shutdown procedure is complete before either removing the sd card or pulling the power plug. There are methods on the web for making your sd card read-only but I can't help you there. Frequent back-ups are an excellent idea too.

As to reviving the old sd card, download the free SD Association "SD Formatter" utility for the Mac and use it to put a new partion on the entire card as FAT32. Then load a new OS. If for any reason the SD Formatter seems not to work, install gparted on the working Pi

Code: Select all

sudo apt-get update 
and

Code: Select all

 sudo apt-get install gparted
and you may have to go to the Devices menu, install a new partition table and then install a new FAT32 partition on the entire sd card. Good Luck!
Last edited by wh7qq on Tue Dec 06, 2016 3:30 am, edited 1 time in total.

Husar
Posts: 67
Joined: Tue Nov 12, 2013 12:43 am
Location: Midwest, USA
Contact: Website

Re: Corrupt SD. Can I recover files?

Tue Dec 06, 2016 3:12 am

This worked perfectly. I put the card in another RPi I have and boom the entire file system is available to me. I went to my old Desktop and move the folder over. Then went to the www directory and grabbed the other files I wanted. Accessing this was was a breeze. I have searched Google and looked at every post and tutorial and not one mentioned this. Thank so much!

Since I can access the file system is there anything else I can try to fix the corruption and get the old sd working again? If not I will just reinstall the OS again.

Thank you,
Ed
Ed

wh7qq
Posts: 1448
Joined: Thu Oct 09, 2014 2:50 am

Re: Corrupt SD. Can I recover files?

Tue Dec 06, 2016 3:32 am

Husar wrote:Since I can access the file system is there anything else I can try to fix the corruption and get the old sd working again? If not I will just reinstall the OS again.

Thank you,
Ed
Best bet is to start from scratch...you don't know for sure what got fu'd.

Husar
Posts: 67
Joined: Tue Nov 12, 2013 12:43 am
Location: Midwest, USA
Contact: Website

Re: Corrupt SD. Can I recover files?

Tue Dec 06, 2016 3:59 am

wh7qq wrote:
Husar wrote:Since I can access the file system is there anything else I can try to fix the corruption and get the old sd working again? If not I will just reinstall the OS again.

Thank you,
Ed
Best bet is to start from scratch...you don't know for sure what got fu'd.
Thanks again. Building new card now.
Ed

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: Corrupt SD. Can I recover files?

Sat Jul 01, 2017 2:11 pm

Hi,
I had a card recently go bad after a month or so of use. I was using it as a influxdb device, writing to it over http API. I tried your method here (thank you for posting!!) and it helped at least identify what's bad with my card. I used this post to see how to mount the usb device. Here are the steps:

- plug SD card into a SD card reader
- plug into RPi
- sudo fdisk -l
- sudo mount /dev/sda2 /mnt

And then this is the error I get. Does anyone know if there is a way to fix the "bad extra_isize"? Or is there more wrong since it says "no journal found" for sda2?
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 93486 85295 41.7M c W95 FAT32 (LBA)
/dev/mmcblk0p2 94208 30916607 30822400 14.7G 83 Linux

Disk /dev/sda: 14.9 GiB, 16001269760 bytes, 31252480 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
Disklabel type: dos
Disk identifier: 0xd01dd90d

Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 92159 83968 41M c W95 FAT32 (LBA)
/dev/sda2 92160 31252479 31160320 14.9G 83 Linux

pi@raspberrypi:~ $ sudo mount /dev/sda2 /mnt
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.
pi@raspberrypi:~ $ dmesg | tail
[ 30.361008] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 30.361025] Bluetooth: BNEP filters: protocol multicast
[ 30.361054] Bluetooth: BNEP socket layer initialized
[ 30.474521] EXT4-fs (mmcblk0p2): resized to 1048576 blocks
[ 30.489317] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 32.021318] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
[ 33.004422] EXT4-fs (mmcblk0p2): resized filesystem to 3852800
[ 100.083277] random: crng init done
[ 273.527515] EXT4-fs error (device sda2): ext4_iget:4479: inode #8: comm mount: bad extra_isize (50890 != 256)
[ 273.676867] EXT4-fs (sda2): no journal found
pi@raspberrypi:~ $

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: Corrupt SD. Can I recover files?

Sat Jul 01, 2017 3:23 pm

Well, I tried using "sudo fsck -y /dev/sda2" and it ran through a TON of fixing, but in the end still wouldn't mount. :-(

wh7qq
Posts: 1448
Joined: Thu Oct 09, 2014 2:50 am

Re: Corrupt SD. Can I recover files?

Sun Jul 02, 2017 1:22 am

Puzzling. Not sure what is going on here but I do not see " -y" as being an available option in Raspbian when I run "fsck -h". Try running it manually even if a PITA. Other than that, it is possible that you Fubar'd the other partition on the uSD card. uSD cards do not survive well with frequent write cycles and you are better served to use a USB memory stick if accessing/writing to it frequently. Considering the low cost of both types (uSD and USB) you may be ahead with replacing rather than beating your head against trying to fix it, but if you have the time and patience, you can try reformatting in a camera or with SDFormatter (free Windows utility) and starting from scratch.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Corrupt SD. Can I recover files?

Sun Jul 02, 2017 2:03 am

wh7qq wrote:Puzzling. Not sure what is going on here but I do not see " -y" as being an available option in Raspbian when I run "fsck -h". Try running it manually even if a PITA. Other than that, it is possible that you Fubar'd the other partition on the uSD card. uSD cards do not survive well with frequent write cycles and you are better served to use a USB memory stick if accessing/writing to it frequently. Considering the low cost of both types (uSD and USB) you may be ahead with replacing rather than beating your head against trying to fix it, but if you have the time and patience, you can try reformatting in a camera or with SDFormatter (free Windows utility) and starting from scratch.
USB sticks have a limited number of write cycles as well. Basically they use the same kind of technology.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Return to “Troubleshooting”