Sometimes, we drop our pen-drive in some water container and our pen-drive either refuses to get detected or files not getting copied to it. We can use our Incredible Ubuntu operating system to get it working. Find below the steps for the same.
1) It is a time-consuming process. Use the 2nd steps only if you actually find any bad-block.
2) All steps need Ubuntu live disk and back-up of data to avoid any loss.
3) The process can be well applied to a hard-disk.
Steps for locating and correcting bad blocks/sectors of the pen-drive :
1) Boot from Ubuntu live disk , open Gparted and check for partition name ( e.g. /dev/sdh1 ) and use the same to replace /dev/sdh1
2) Looking for bad blocks ( via terminal )
The first step is to locate the bad blocks of each partition. Type in the following command to do a search using the non-destructive way (-n), showing the progress (-s) and dumping the bad blocks in the file "badblocks_1GB01.txt" .
sudo badblocks -n -s -v /dev/sdh1 -o badblocks_1GB01.txt
2) Formatting the drive
You have to pass the list of blocks obtained in the previous step, for which the command to use to format in FAT32 is:
sudo mkdosfs -F32 -v -n "1GB" -l badblocks_1GB01.txt /dev/sdh1
Here -F32 is for FAT32 partition and "1GB" is the partition size .
This will render the badblocks un-available for use leaving all the usable blocks on the pen-drive for use.