23 - How to fix a 'corrupt' USB drive that causes Windows or RMPrepUSB to stop responding
Unique page hits
Fix USB drive that Windows has problems accessing or gives 'permission' error when accessed!
Tip: If you have a USB Flash drive that reports 'No Media' in Disk Management - try this Transcend JetFlash Repair utility.
Sometimes a perfectly good USB drive can become corrupt due to invalid data in the Master Boot Record (MBR) or Partition Boot Record (PBR) or directory structure on the USB drive itself. Once this has happened, and you then insert the USB drive into a USB port of your Windows computer, Windows or a utility such as RMPrepUSB may become unresponsive when accessing that device. If this happens THERE IS NO NEED TO THROW THE USB DRIVE AWAY - YOU CAN FIX IT!
First though - do you need to recover any files from it? If so, even though you may think it does not have any files on it and even though you have formatted it since it went wrong, you may be able to recover some files from it - see Tutorial #28 first.
To reprogram a fake flash memory drive or one that has bad developed bad memory blocks, you will need to find the manufacturers tool and program it with the correct capacity - for details on how to do this see Tutorial #39.
What we need to do is wipe the contents of the drive so we can re-partition and re-format it again, but to do this we obviously cannot use Windows! One method is to boot to WinPE and run Diskpart. If you have a Windows Vista or Windows 7 computer or Recovery DVD then you can easily boot to WinPE and fix it as follows:
Remove the USB drive from the computer
Reboot the Win7/Vista computer and before it starts to boot to Windows again, keep pressing and releasing the F8 key until you see a text menu appear - then choose the Repair option.
If you do not see a menu or you do not have the Repair option in the menu, you must boot from the Recovery DVD instead.
Once booted and you have entered your account password, choose the Command Console/Prompt option.
You should now be at the WinPE command prompt - usually white text on a black background with a command prompt displayed (e.g. X:\Windows\System32> ).
Type DISKPART and then LIST DISK
Now insert the rogue USB drive into the USB port of the computer , wait a few seconds and type LIST DISK again - you should now see the USB drive listed as well as other drives.
Now type SELECT DISK X (where X is the drive number of your USB drive that was listed in step 6) e.g. SELECT DISK 1
Type LIST DISK againand make sure the * is next to your USB pen drive as we are about to wipe it.
Now type CLEAN (WARNING: BE VERY SURE you have selected the correct disk number in step 7 or you could wipe your hard drive instead!)
Now type WPEUTIL REBOOT to reboot your computer and then in Windows use RMPrepUSB to Quick Test your USB drive to check it is all OK and then reformat it with RMPrepUSB - Prepare Drive.
Explanation of why Windows freezes when accessing a corrupt device
Let us suppose that the Master Boot Record (MBR - the first sector or block on the drive) of the USB drive contains bad data in the partition table and that it says that the first partition on the drive starts at block 98,000 - but the drive is physically only 90,000 blocks in size! Windows will try to access the Partition Boot Record (PBR) at block 98000 (which of course does does not exist) and the drivers will request that block's data to be sent from the USB flash drive. As the block does not exist, the access waits for the block to become available (i.e. waits for the disk platter to rotate and the drive head to seek to the correct sector - even though we know it does not have such things, Windows does not!). Now if a hard drive attempts to access a sector, it may be necessary to do retries, recalibrations, re-seeks and re-reads. All this takes time, as the driver must wait for a response from the drive. Eventually the driver time-out happens and the driver gives up and returns an error. Now Windows says to itself 'but I really need this data as it could be really important - like a boot file or something' and so Windows sends another command to the flash drive to get block 98,000 again. Yet again (after a sufficient wait and time-out), an error is returned and yet again the driver repeats the command. This can go on many times (depending on Windows and the drivers re-try algorithm) until eventually Windows just gives up and reports an error. By then your beard has grown another inch! Of course, linux has no such problems as it is coded properly!
Keywords: USB, corrupt flash drive, thumb drive, not responding, slow, freeze, hang, stop, access, bad, cheap, fake, pen drive