How To Repair an USB Drive with Errors in Linux
To store our documents, we use cloud storage services or USB flash drives.
Most of us have some USB memory to store all this information and can quickly move documents and other files between different computers.
Sometimes these devices have errors that don't allow the Linux system to detect them and this way we will have difficulties for the optimal work with them.
In this tutorial, we will analyze how to correct this type of errors in Linux, and for this case, we will use Debian 8.
Check and Eliminate Corrupt Blocks
The FSCK (File System Check) command is a great help for the correction of the different errors presented in the flash or USB memory since the FCSK tool eliminates all the corrupt blocks to optimize the operation of the same.
Before using this command we must verify which is the identifier of the USB drive, for this, we will use the command
There we can verify that the ID sda1 identifies our USB drive. To use the FSCK utility, we can use any of the following syntaxes:
- We can specify a particular partition using /dev/ID_Partition
- We can define an entire disk using /dev/sdc
In this case, we will use the partition associated with our USB so we will introduce the following:
sudo fsck /dev/sda1
The parameters that we can implement when using FSCK are the following:
- -a: Repair the system automatically
- -c: Check the disk blocks
- -v: Provide more information
- -f: Force verification
- -r: Enable interactive mode
- -y: Use the answer YES
Reduce USB drive to Zero
This option can be applied when the unit is illegible, and we must eliminate all the data included in it, and the most practical way to perform this task is using the command dd We can use the following syntax.
If it is only the partition:
sudo dd if=/dev/zero of=/dev/sd1
If we apply this to the entire disk:
dd if=/dev/zero of=/dev/sdc
Create New File System
Another option that we have available for correcting the errors of our USB memories is to modify the file system of the memory so that everything starts from scratch. We can use the following syntax depending on the type of file system. (remember to take into account the memory ID)
sudo mkfs.ext4 -f /dev/sda1
sudo mkfs.msdos -f 32 /dev/sda1
sudo mkfs.ntfs -f /dev/sda1
In this way, we can manage the possible errors in the USB drives in our Linux.