How to check the health status of a USB stick?
How do I know that a USB is broken beyond repair, or repairable?
|
How to check the health status of a USB stick? How do I know that a USB is broken beyond repair, or repairable? |
|||||||||||||
migrated from serverfault.com Jan 9 '12 at 4:16This question came from our site for system and network administrators. |
|||||||||||||
|
|||||||||||||
|
There is no way to query a USB memory stick for SMART-like parameters; I'm not aware of any memory sticks which support doing so even via publicly-available proprietary software. The best you can do is to check that you can successfully read+write to the entire device using https://en.wikipedia.org/wiki/Badblocks You want to specify one of the write tests, which will wipe all data on the stick; make a backup first. Find the device by looking at If the stick is formatted with a valid filesystem, you may have to Example syntax, for a USB stick enumerated as /dev/sdz, outputting progress information, with a data-destructive write test and error log written to usbstick.log:
You'll need to repartition and reformat the stick afterwards, assuming it passes; this test will wipe everything on the stick. Any failures indicate a failure of the device's memory controller, or it has run out of spare blocks to remap failed blocks. In that case, no area of the device can be trusted. |
|||||||||||||||||||||
|
|
Via [ubuntu] Error Check USB Flash Drive, I eventually found this, which could be helpful:
Addendum by @pbhj: F3 is in the Ubuntu repos. It has two part, f3write writes 1GB files to the device and f3read attempts to read them afterwards. This way capacity and ability to write and effectively read data are tested. |
|||||||||
|
|
It depends on the failure mode, I suppose. They're cheap for a reason. As a USB device, watching the bus via device manager in Windows or the output of dmesg in Linux will tell you if the device is even recognized as being plugged in. If it isn't, then either the controller on board or the physical connections are broken. If the device is recognized as being plugged in, but doesn't get identified as a disk controller (and I don't know how that could happen, but...) then the controller is shot. If it's recognized as a disk drive, but you can't mount it, you might be able to repair it via fdisk and rewrite the partition table, then make another filesystem. If you're looking for the equivalent of S.M.A.R.T., then you won't find it. Thumbdrive controllers are cheap. They're commodity storage, and not meant to have the normal failsafes and intelligence that modern drives have. |
|||
|
|
|
Many failures are either complete or allow one location to support multiple locations. I wrote a little random write read program that uses a prime number for a pseudo-random number generator, for both patterns and addresses. The reads are staggered behind the writes by enough pages to ensure I am not testing ram cache on the system. It is not yet parameterized, just set up for a 64G device on my system with 8G ram. Feel free to criticize, parameterize, make it smarter. This is a powerful check and faster than doing every byte bottom to top, but is also a great swap generator (rolls almost everything else out). I put swapiness at 1 temporarily and it became slower but more tolerable to other apps. Any tips on how to tune against swapout would also be appreciated: $ sudo ksh -c 'echo 1 > /proc/sys/vm/swappiness'
|
|||||||||
|
|
USB drives are pretty rudimentary, there's not a lot that can go wrong on them! Generally, if it shows up as a drive and you can format it then it works. You could try having a look at the Portable version of CrystalDiskInfo as that's a quick lightweight analysing tool. Very few USB sticks report back S.M.A.R.T. info and the like though. |
|||||
|