0

Yesterday, I plugged in an SD card with a bunch of video data acquired by my Raspberry Pi into my Ubuntu computer. The SD card mounted with the usual boot and OS partitions. Like an idiot, I did not copy the video files over. Now, when I plug the SD card in, only boot mounts, and there's strange characters in the file name. I can't get into the Pi /home directory at all, which means I can't get the videos.

When I type:

parted /dev/sdc print

I get

Model: USB Mass  Storage Device (scsi)
Disk /dev/sdc: 129GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  62.9MB  58.7MB  primary  fat16        lba
 2      62.9MB  129GB   129GB   primary

I have not been able to figure out how to mount #2. The Pi will no longer boot on its own so I can't get in that way.

Trying to mount the partition with ext3, ext4, vfat, or msdos gives some variant of the following:

mount -t ext4 /dev/sdc2 /media/pi

returns:

mount: wrong fs type, bad option, bad superblock on /dev/sdc1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

And:

dmesg | tail

gives:

[2068799.476208] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00006520)
[2068799.476329] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00006c6c)
[2068799.476397] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00007620)
[2068799.485943] FAT-fs (sdc1): error, invalid access to FAT (entry 0x000076b3)
[2068799.486050] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00006e65)
[2068799.495272] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00006001)
[2068799.495389] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00004000)
[2068799.495505] FAT-fs (sdc1): error, invalid access to FAT (entry 0x00006573)
[2068799.495564] FAT-fs (sdc1): error, invalid access to FAT (entry 0x0000414d)
[2068946.845907] EXT4-fs (sdc2): VFS: Can't find ext4 filesystem

Trying to mount as vfat or msdos gives:

dmesg | tail
[2069137.546806] FAT-fs (sdc2): bogus number of FAT structure
[2069137.546809] FAT-fs (sdc2): Can't find a valid FAT filesystem

Trying to mount as ntfs gives:

NTFS signature is missing.
Failed to mount '/dev/sdc2': Invalid argument
The device '/dev/sdc2' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

dmesg | tail

[2069279.102188] usb 2-6: reset high-speed USB device number 27 using ehci_hcd
[2069279.358047] usb 2-6: reset high-speed USB device number 27 using ehci_hcd
[2069279.490651] sd 26:0:0:0: [sdc] Unhandled error code
[2069279.490654] sd 26:0:0:0: [sdc]  Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[2069279.490657] sd 26:0:0:0: [sdc] CDB: Read(10): 28 00 00 01 e2 00 00 00 08 00
[2069279.490661] end_request: I/O error, dev sdc, sector 123392
[2069279.490665] Buffer I/O error on device sdc2, logical block 64
[2069279.605895] usb 2-6: reset high-speed USB device number 27 using ehci_hcd
[2069280.444934] sd 26:0:0:0: [sdc] No Caching mode page found
[2069280.444937] sd 26:0:0:0: [sdc] Assuming drive cache: write through
2

Something bad happened to the filesystem. It may or may not mean lost data.

If you are very concerned about what's there, you may want to create a copy of the partition using dd before you do anything else. It does not care whether the fs is intact or not.

dd if=/dev/sdc2 of=sdc2.img

This is only useful if the repair fails, or you lose stuff you really didn't want to lose, since in either case the repair may change things. If it fails, you have a more difficult problem and should ask about salvaging stuff from an ext4 filesystem on Unix & Linux.

To try and repair it:

sudo e2fsck /dev/sdc2

It may ask various questions about the repair. You can just say yes to everything. If the damage is bad, this may go on for a while.

Afterward, run e2fsck again just to be sure. It should now say everything is okay, and you should be able to mount the partition (as ext4). Then have a look in lost+found/ at the top level of that partition. Normally this directory is empty. If there is anything in it, it was put there during the repair and indicates pieces of a file that could not be identified and restored.

0

In the end I was able to use PhotoRec to extract data from the sdc2 partition. I tracked down the log file that gave information on when the videos were written. Unfortunately PhotRec can't recover the file names of the videos, so I'm currently trying to track them down.

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.