1

I have an SD card which was used in Raspberry Pi. I want to mount this SD card on a Linux PC to get files from it, but I can't.

When I put the SD card in a card reader, my dmesg says:

  [  114.117896] usb 4-1: new full-speed USB device number 2 using ohci-pci
  [  114.292885] usb 4-1: New USB device found, idVendor=214b, idProduct=1101
  [  114.292897] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  [  114.292904] usb 4-1: Product: USB2.0 Device   
  [  114.292910] usb 4-1: Manufacturer: Generic 
  [  114.292914] usb 4-1: SerialNumber: 0201202010201000
  [  114.383603] usb-storage 4-1:1.0: USB Mass Storage device detected
  [  114.383803] scsi6 : usb-storage 4-1:1.0
  [  114.383956] usbcore: registered new interface driver usb-storage
  [  115.386965] scsi 6:0:0:0: Direct-Access     USB2.0   CARD-READER      1.01 PQ: 0 ANSI: 2
  [  115.388961] sd 6:0:0:0: Attached scsi generic sg2 type 0
  [  115.409892] sd 6:0:0:0: [sdc] Attached SCSI removable disk
  [  115.471798] sd 6:0:0:0: [sdc] 30679040 512-byte logical blocks: (15.7 GB/14.6 GiB)
  [  115.505782] sdc: detected capacity change from 0 to 15707668480
  [  115.534776]  sdc: sdc1 sdc2 < sdc5 sdc6 > sdc3

The partition table of this card is:

  # parted /dev/sdc
  GNU Parted 3.2
  Using /dev/sdc
  Welcome to GNU Parted! Type 'help' to view a list of commands.
  (parted) print                                                            
  Model: USB2.0 CARD-READER (scsi)
  Disk /dev/sdc: 15,7GB
  Sector size (logical/physical): 512B/512B
  Partition Table: msdos
  Disk Flags: 

  Number  Start   End     Size    Type      File system  Flags
   1      1049kB  1275MB  1274MB  primary   fat32        lba
   2      1278MB  15,7GB  14,4GB  extended
   5      1279MB  1342MB  62,9MB  logical   fat16        lba
   6      1343MB  15,7GB  14,3GB  logical
   3      15,7GB  15,7GB  33,6MB  primary

When I check this device with fdisk, it says:

  # fdisk /dev/sdc -l

  Disk /dev/sdc: 14.6 GiB, 15707668480 bytes, 30679040 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: 0x000daf86

  Device     Boot    Start      End  Sectors  Size Id Type
  /dev/sdc1           2048  2490234  2488187  1.2G  e W95 FAT16 (LBA)
  /dev/sdc2        2496512 30609407 28112896 13.4G 85 Linux extended
  /dev/sdc3       30613504 30679039    65536   32M 83 Linux
  /dev/sdc5        2498560  2621439   122880   60M  c W95 FAT32 (LBA)
  /dev/sdc6        2623488 30607359 27983872 13.4G 83 Linux
  Partition table entries are not in disk order.

It seems that /dev/sdc6 is the biggest partition, so I want to mount it. When I try to mount it, I get this result:

  # mount -v /dev/sdc6 test
  mount: wrong fs type, bad option, bad superblock on /dev/sdc6,
         missing codepage or helper program, or other error

         In some cases useful info is found in syslog - try
         dmesg | tail or so.

Dmesg doesn't say anything when I try to mount /dev/sdc6.

When I check this partition with file command, it says:

    # file -s /dev/sdc6
    /dev/sdc6: data

When I check the filesystem with fsck, I get:

  # LC_ALL=C fsck.ext3 -n /dev/sdc6
  e2fsck 1.43.4 (31-Jan-2017)
  ext2fs_open2: Bad magic number in super-block
  fsck.ext3: Superblock invalid, trying backup blocks...
  root was not cleanly unmounted, check forced.
  Pass 1: Checking inodes, blocks, and sizes
  Pass 2: Checking directory structure
  Pass 3: Checking directory connectivity
  Pass 4: Checking reference counts
  Pass 5: Checking group summary information
  Free blocks count wrong for group #0 (4245, counted=11608).
  Fix? no

  Free blocks count wrong for group #1 (1373, counted=707).
  Fix? no

  Free blocks count wrong for group #2 (1699, counted=1880).
  Fix? no

  (...)

  Inode bitmap differences:  -(57345--131072) -172034 -172037 -(172042--172043) -172045 -172047 -172049 -172053 -172057 -172059 -172062 -172065 (...)
  Fix? no

  root: ********** WARNING: Filesystem still has errors **********

  root: 91692/876544 files (0.8% non-contiguous), 1413337/3497984 blocks

I understand that due to some unknown reason Linux can't mount this filesystem. I would like to know why - is filesystem broken, or is there some other reason? And I would like either to mount this filesystem or somehow recover its files.

What should I do now to troubleshoot this problem?

EDIT: I want to thank everybody for help! Finally I found - using fsck - that the partition does contain Linux ext filesystem, but the filesystem is broken and this is why I could not mount it. I did a backup of the card (with "cat /dev/sdc | gzip > mybackup") and then checked if the device contains bad blocks. It does not contain any bad blocks (maybe the filesystem on the SD card was broken by usind it with a broken SD card reader?), so I just fixed the filesystem with fsck, put the card in the Raspberry Pi and then it booted without problems.

  • Are you running that on the Raspberry or on another Linux PC ? – Basile Starynkevitch Oct 1 '17 at 6:05
  • I run it on another Linux PC. – user983447 Oct 1 '17 at 6:08
  • That should go into the question – Basile Starynkevitch Oct 1 '17 at 6:14
  • Done - I added an information that I want to mount it on a Linux PC. – user983447 Oct 1 '17 at 6:17
  • 1
    What is the output of fsck.ext3 -n /dev/sdc6? The -n option means that no changes will be made. – VPfB Oct 1 '17 at 6:31
2

According to the posted fsck output, there is hope that some data might be recovered.

I would recommend:

  1. make a dd copy of the filesystem to a disk file (e.g. fdsump.orig). If it fails, try ddrescue. Make sure you have enough free space before you begin.
  2. Do not work directly on this file, but create a new copy (e.g. cp fsdump.orig fsdump), so you can always return to this step and start again.
  3. with mount -o loop create a device from the fsdump data file (e.g. /dev/loop1)
  4. try fsck.ext3 /dev/loop1 until there will be no errors. The more passes will be needed, the bigger is the damage.
  5. mount the /dev/loop1 to a directory. Copy all files to a safe location. (Use cp -a or rsync to preserve file attributes). Any of them may be corrupted, truncated, etc.
  6. You may now umount the loop filesystem.

See man pages of the mentioned utilities for details.

1

You might use file(1) as file -s /dev/sdc6 this would read some bytes from the block device and guess what is there.

If nothing is recognized, you are in trouble and you might have lost your data; to do anything to recover it, you should know a priori what file system was there.

If some file system is recognized, you could try to use mount(8) with an explicit -t type

Partition table entries are not in disk order

This smells not very good. Perhaps you'll need to repartition entirely your disk (but backup its data before); it looks that you have two partitions overlapping (sdc2 and sdc6)

Since you are running on some other Linux PC, you could copy the data from the SD card to the PC (into some file), perhaps using dd(1)

dd if=/dev/sdc6 of=$HOME/diskdata bs=4k

BTW, do check with dmesg after that command that the copy went well.

You could even copy with dd the entire SD card.

Then you might spend hours (or months) of work to try to decipher the mess in that $HOME/diskdata file on your Linux PC. You could use debugfs(8) for that purpose, if you believe the original file system was ext3 or ext4

SD cards are fragile devices and they wear out quickly. I guess yours is physically broken. Prepare yourself to some definitive data loss.

  • I added the output of "file -s /dev/sdc6" to the question body. – user983447 Oct 1 '17 at 6:05

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.