Corrupt data on USB flash drive Repair?

Discussion in 'HOWTO-Related Questions' started by david_d, Sep 25, 2019.

  1. david_d

    david_d New Member

    I have a USB flash drive with corrupt data that makes it completely unreadable. How can I repair it? Or would it be more trouble than it's worth and if so how do I wipe it so it is usable again. The data on it isn't extremely important to me but I would still like to have it. Also if it helps, I believe I am on the latest version of fedora. Please link any tutorials you think might be useful as well. Thank you.
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    If you have files you need to get from that USB flash drive, use Photorec. Your Linux distribution may have package testdisk, which contains Photorec. Another possibility is ddrescue.
    If you then want to repair that flash drive, remove partitions on that device and create new partition or partitions. Then create filesystem on those partitions. To do this, find device name for that flash drive. Do
    Code:
    dmesg | tail -20
    then insert the USB drive.
    Then do again
    Code:
    dmesg | tail -20
    The last lines that were added should show you which disk device name that drive is.
    Then use fdisk, gdisk or similar to manipulate partitions. Read the manpage first for the command you use.
    Finally create filesystem, read man mkfs.
     
  3. Hello, @david_d
    Please follow these steps, it may solve your problem:
    Delete The Partitions Using FDisk
    Step 1
    :- Open a terminal window and type below command:
    sudo fdisk -l
    Step 2
    :- In the a drive is a device and a device is handled much like any other file. Therefore the drives are named /dev/sda, /dev/sdb, /dev/sdc and so on, if you have the correct drive type the following command:
    sudo fdisk /dev/sdX Note:- Replace the X with the correct drive letter.
    Step 3:- This will open a new prompt called "Command". The "m" key is very helpful with this tool but basically you need to know 2 of the Commands. This first is delete.
    Step 4:-
    Enter d and press the Enter key. If your USB drive has more than one partition it will ask you to enter a number for the partition you wish to delete.
    Step 5:-
    The next step is to write the changes to the drive.
    Enter w and press return.
    Step 6:- You now have a USB drive with no partitions. At this stage, it is completely unusable.

    Create A New Partition
    Step 1:- Within the terminal window open fdisk again as you did before by specifying the name of the USB
    sudo fdisk /dev/sdX Note:- Replace the X with the correct drive letter.
    Step 2:- Enter N to create a new partition.
    Step 3:- Choose between creating a primary or extended partition.Choose P for primary.
    Step 4:- Enter how many number of partition you need and press Enter.
    Step 5:-
    To use the whole drive press return twice to keep the default options.
    Step 6:- Enter W and press return.

    Refresh The Partition Table
    Enter the command in the terminal to refresh partition: sudo partprobe.
    Create A FAT Filesystem

    Type command in terminal for create a FAT Filesystem: sudo mkfs.vfat -F 32 /dev/sdX1
    Note:- Replace the X1 with the correct drive letter.

    Mount The Drive
    To Mount the drive run the following commands:
    sudo mkdir /mnt/sdX1
    sudo mount /dev/sdX1 /mnt/sdX1

    Note:- Replace the X1 with the correct drive letter.

    I hope above information will be useful for you.
    Thank you.
     
    Last edited: Oct 1, 2019

Share This Page