1

I accidentally formatted my USB drive which was formatted in ext4 to exfat using the command

mkfs.exfat /dev/sdb1

I was trying to recover it using testdisk. It was able to detect the filesystem, but couldn't read it and gives me a warning of damaged file system.

So tried using sudo fsck.ext4 /dev/sdb1, which will repair the damaged file system. But when tried to mount, I was getting the below error :

arun@lenovo-pc:~/Desktop/testdisk-7.0$ sudo mount /dev/sdb1 /media/usb2
mount: /dev/sdb1: more filesystems detected. This should not happen,
       use -t <type> to explicitly specify the filesystem type or
       use wipefs(8) to clean up the device.
arun@lenovo-pc:~/Desktop/testdisk-7.0$

I tried with sudo mount -t ext4 /dev/sdb1 /media/usb2 the it is able to mount properly and I was able to see the lost data.

But my question is why fsck can not properly repair the first sectors. Is there a way to properly repair the first sectors to properly rectify the damage done by mkfs.exfat command, so that I can mount directly with out any issues ?

2
  • Does the partition table show the partition as being exFAT or EXT4? Commented Jul 2, 2016 at 9:31
  • Well e2fsck certainly would not be aware of what/where other filesystem put their header on a partition. It might be able to repair the structure of ext4, but that may not necessarily mean all the exfat information is cleared.
    – Tom Yan
    Commented Jul 2, 2016 at 12:23

2 Answers 2

1

fsck.ext4 is a tool to check EXT4 file systems for errors that occur during faulty "normal" use, e.g. power failures or kernel panics that leave data partially written. Reformatting a partition on which an EXT4 file system lives really isn't the kind of error fsck is meant for.

I would say that by far the easiest and least dangerous way to restore the file system is to first mount it by explicitly specifying the file system type like you said and copy over the files to another file system. Then properly reformat the USB drive as EXT4 (see man mkfs.ext4) and copy the files back. Repairing file systems in place is not impossible, but it's incredibly easy to do even more damage.

-1

That certainly does not appear to be a real issue. It seems your only problem is that the filesystem type is not detected automatically and which you can easily solve by placing the correct entry in your /etc/fstab, or specifying it on the command line as you did.

Do note that it's much more practical to refer to partitions by their UUID which remains the same however you connect the device and regardless of the order they were connected.

In the worst case scenario, just make a backup of your partition contents and another drive, reformat it, and restore the backup.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .