An example of USB flash drive Detection

Source: Internet
Author: User

An example of USB flash drive Detection

Recently, it is rumored that a roommate's USB flash drive often Copies files but cannot be used. I tried to reformat the file several times, and the effect was not good. So later, out of righteousness, I helped him study the following. In the end, although we could not repair our minds, it took a lot of effort to detect our minds.
First of all, you must use Windows formatting. Do not select "quick formatting". The result is not found. It can be seen that the disk formatting function of Windows is only applicable to disks. At the hardware level, every time windows reads data from a disk, it must transmit more than 20 parameters, including multiple commands and error detection. In the era of USB flash drives, the improvement of hardware reliability has omitted some error detection functions. Therefore, problems cannot be found through full formatting.
Then, HD tune, a classic hard disk track detection tool, was used, and no problems were found in the actual detection. The detection results were all small green blocks. From this we can also see that the tool for disk detection is really not applicable to the USB flash disk. I am very disappointed.
Finally, a CD check tool is used. CD check is a data error detection tool. It is not only applicable to optical disks, but also widely used. You can use four functions: Data check and file, Data check, data file comparison, and damaged disc data recovery. We used the build checksum and Data check functions in the USB flash drive bad zone this time.
No matter which part of the process involves data transmission, writing, storage, and reading, the final result is that the read data is different from the original data. In this way, the file checksum tool can be used to find the damaged file and overwrite the damaged data block to prevent future harm to other data. The data checksum function uses the existing Algorithm Extract A feature value from the data. As long as the data changes, the feature value is almost certainly changed (the possibility of changing the data and the feature value is inconvenient is extremely low, so you do not need to consider it ).
So our approach is to fill the entire USB flash drive with files, and then verify each file. Once the feature values of a file are different, it is determined that the data block of the file is damaged. Of course, to ensure that no Bytes are left blank, the file size must be an integer multiple of the smallest cluster size. Generally, you can select FAT32 partitions and an integer multiple of 4 kb. In this test, I chose a file of 1 MB for fast speed.
About how to generate a file that is exactly 1 MB. You can use the WinRAR volume compression function to select a large volume of data, and then use WinRAR to compress the data. When compressing the data, set the size of the volume to 1048576b (1 MB ). The generated file is exactly 1 MB apart from the last one. You can just use one of them. Of course, we only need a 1 MB file instead of a compressed package. If you look uncomfortable, you can change it to another extension. And put this 1 MB file into a separate folder.
Use CD check to create a checksum and enable CD check (My v3.1.8.0 has a 30-day trial ). Go to the hash function, select the folder where the 1 MB file is saved in source folder, and then select continue. A. CRC file is generated in this folder, that is, the checksum file. It is a text file and can be opened in notepad. After opening the file, you can find that it is only a list in the directory tree order. Each file has its own feature value (MD5 verification code ). Modify this file, copy and paste a row with a verification code repeatedly, and change the file name to a certain sequence. It is best to use sequential numbers. I used hexadecimal numbers at the time, because it is easy to identify bad block addresses. Note that the total file capacity should be close to the U disk capacity rather than exceeding.
Create a folder on the USB flash drive, copy the CRC check file to the folder, and copy the 1 MB file to the folder repeatedly. Note that you need to change the file name to the file name in the CRC file before each copy, until the file list in the CRC file exists. In this way, if there are still remaining files, copy the 1 MB file and add the file name to the CRC file.
When copying a file, you need to follow the order of numbers in the file name to determine the location of the Bad block. In the future, you will consider re-partitioning to block the bad block. After all the copies are complete, start CD check again, select source folder as the folder on the USB flash drive, and then select the CRC file in the custom hash file folder-> continue, check the file. The following list shows which file is damaged.
If you are a lazy, you can cut the damaged files into a hidden folder and no longer use the space occupied by these bad blocks. Of course, this method can be used at the moment. Never format, repartition, or sort or delete bad block files on disks. Otherwise, it is very troublesome to search for these bad blocks again. If you are a smart person, you can determine the location of Bad blocks through the file name of a 1 MB file to re-partition and shield the Bad blocks. Even if the number is used to name the readers, you can delete all files without bad blocks and then enter the disk for sorting. Program , Select analysis to view the location of the Bad Block file to re-partition.
My example: a mb usb flash drive (the brand will not be mentioned, without the suspicion of advertising ). Free Space: MB and kb. Four copies of a 1 MB file are copied into one folder. Each folder name is named in two hexadecimal notation, when performing the verification check, use custom hash file to specify the CRC file as an existing CRC file. Then, each folder is verified once. Finally, we found 3 1 MB files containing Bad blocks between 60-64 MB. Because it is not my USB flash drive, I am too lazy to help him partition again, so I used the lazy method, using Autorun. when you access a USB flash drive, INF starts a description file and does not allow users to repartition, format, or delete bad block files.
Special case: This method is more convenient to test a large number of consecutive Bad blocks. However, when a bit (1 bit) is added, the write status is the same as the corrupt status, this corrupted bit cannot be found. It can only be written for verification once for the first time. After that, all the bits in the data are reversed by bit, the verification file is re-generated and re-verified, in this way, we can find all the bad blocks.
Versatility: although the method used in this example is clumsy, there is a possibility of omission, but the versatility is very high, not only limited to the detection of USB flash drives, it can also be used to detect mobile hard disks and other read/write storage devices. In addition, the possibility of false positives is lower than that of Windows formatting and HD tune.
I hope this article will be useful. I also hope that readers can find hidden enemy and enemy elements from their mobile storage devices as soon as possible. Good luck!
2005-11-3 @ Hebei sci-tech thermal apartment by gashero Liu.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.