0

I got a problem with my SD card which had got Raspbian. Everything seemed to be ok while working with the raspberry.

I inserted it to my laptop running Ubuntu 12.04.4 to fetch some files. It first couldn't load the files from Home partition (boot partition was shown too)so I tried to unmount it from nautilus and ejected the card manually.

Then, when I inserted the card again, it showed one only partition named "+00, and all it shows are files with out any format or extension known and with weird names.

Tried to boot the raspberry with the card but naturally it didn't boot at all.

fdisk -l output:

Disk /dev/sdb: 8068 MB, 8068792320 bytes
249 heads, 62 sectors/track, 1020 cylinders, total 15759360 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: 0x000981cb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdb2          122880    15759359     7818240   83  Linux

How can I recover my files? More than the system I care about some files at my /home directory

3
  • Have you tried fsck yet?!? If fdisk can see partitions, you should be able to e2fsck /dev/sdb2.
    – goldilocks
    Commented Mar 3, 2014 at 14:55
  • I got: Superblock has an invalid journal (inode 8). Clear<y>? Commented Mar 3, 2014 at 16:00
  • Remember to make sure it's the second partition (sdb2)! You might as well say yes to everything -- in fact it's easier automated, e2fsck -y, since sometimes there can be a lot of errors. You may lose some data because of this; after the fsck you should be able to mount the partition, then look in /lost+found -- recovered partial files will be in there, although without their original names.
    – goldilocks
    Commented Mar 3, 2014 at 17:07

1 Answer 1

3

First try to raw-copy the entirety of data on the card, byte by byte. You may even want to set the little lever on the card to read-only or lock or whatever it says

dd if=/dev/sdX of=~/backup.img

Where sdX is your card. It may also be sth. like mmblc or so.
Do NOT add a number behind X, so that (if any are still detected) all partitions are copied.
Now you have a bytewise copy of your data.
Next thing I'd do is run gparted and see if it suggests you some fixes. Broken partition tables can sometimes be fixed with it.

In case you think you worsened it: Go back to the backup.

dd if=~/backup.img of=/dev/sdX

Things to be careful about

  1. This is all based on the assumption that the SD-Card is working correctly, hardware-wise
  2. when using dd: WATCH what you're doing. use /dev/sda as of and normally you just corrupted your entire harddrive
  3. dd does not give any status feedback. You can tell it is running by the console being blocked and maybe a light blinking on your SD-slot, depending on hardware. reference your SD-cards size and class to get an estimate of the time to expect. See wikipedia
6
  • I will check it, see my last edit. Partitions seem to be still there Commented Mar 3, 2014 at 13:49
  • 1
    @diegoaguilar the tricky question is now: How come fdisk can tell the partitions etc. apart, but nautilus cannot or at least not make sense of it. Have you tried mounting "manually" (mount /dev/sdb /mnt/sdb)?
    – Mark
    Commented Mar 3, 2014 at 13:53
  • I gave +1 to your comment. I had not tried last. But I think that being nautilus an end user app .... Commented Mar 3, 2014 at 13:57
  • @diegoaguilar maybe natilus mounts it wrong. If, let's say your partition was with an ext4 fs but natulius mounted it as ext3 that would explain how it does "work"(files are there) but not correctly(nonsense names and all). When you mount manually you can specify which fs is to be used. Might help if you know the correct values for your card. This crossed my mind because I saw W95 FAT32 (LBA) in your fdisk promt, which is a fs I've never seen actaully being used.
    – Mark
    Commented Mar 3, 2014 at 14:08
  • So, after seeing output of fdisk -l you suggest me to try with the instructions first given at your answer? Commented Mar 3, 2014 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.