1

I've got a USB pen drive with a corrupted FAT filesystem. Now I try to repair it. So to first try what I can get from it without endangering the original hardware further, I've created an image with dd using the following command line:

$ sudo dd if=/dev/sdb of=pendrive.img

Now I want to repair the filesystem in the image by running fsck.

But fsck immediately terminates as follows:

$ sudo fsck.vfat -a -t -v pendrive.img
fsck.fat 3.0.27 (2014-11-12)
Logical sector size is zero.

Is there any trick how I can tell fsck to assume a sector size or what does this message mean? Can somebody help interpreting this output?

This question is similar to fsck a filesystem in a file but this was about ext2. Also https://superuser.com/questions/129189/cant-mount-fat32-drive-under-ubuntu-linux gave no answer.

white_gecko
  • 257
  • 1
  • 3
  • 11

1 Answers1

4

You have made the image of your whole USB pen drive with your dd command. This means that the image includes also a partition table.

That is why you cannot mount the image directly as a file system.

To mount the filesystem inside the image, you need to use kpartx utility to generate virtual devices from the partition table in your image.

kpartx -v -a /path/to/image

will create new partition mappings inside your /dev/mapper directory, which will point to the actual partitions inside your image. Then you can use these entries as the device for mount command or for fsck.vfat command.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58