How do I check the integrity of a storage medium (hard disk or flash drive)?












60















I've run across (personally or by proxy) a bunch of storage media that exhibited physical problems during their life. Hard disks, solid state drives and other flash storage media all fail after some time. The situation is worse with USB flash drives and flash cards because of the large amount of suppliers with inferior flash cell and flash controller quality.



How can I reliably detect if a storage drive suffers from physical damage?



Note that this question isn't about file system integrity (which can be checked with fsck(8)).










share|improve this question





























    60















    I've run across (personally or by proxy) a bunch of storage media that exhibited physical problems during their life. Hard disks, solid state drives and other flash storage media all fail after some time. The situation is worse with USB flash drives and flash cards because of the large amount of suppliers with inferior flash cell and flash controller quality.



    How can I reliably detect if a storage drive suffers from physical damage?



    Note that this question isn't about file system integrity (which can be checked with fsck(8)).










    share|improve this question



























      60












      60








      60


      37






      I've run across (personally or by proxy) a bunch of storage media that exhibited physical problems during their life. Hard disks, solid state drives and other flash storage media all fail after some time. The situation is worse with USB flash drives and flash cards because of the large amount of suppliers with inferior flash cell and flash controller quality.



      How can I reliably detect if a storage drive suffers from physical damage?



      Note that this question isn't about file system integrity (which can be checked with fsck(8)).










      share|improve this question
















      I've run across (personally or by proxy) a bunch of storage media that exhibited physical problems during their life. Hard disks, solid state drives and other flash storage media all fail after some time. The situation is worse with USB flash drives and flash cards because of the large amount of suppliers with inferior flash cell and flash controller quality.



      How can I reliably detect if a storage drive suffers from physical damage?



      Note that this question isn't about file system integrity (which can be checked with fsck(8)).







      hard-drive usb-drive






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 20 '14 at 7:35









      Braiam

      52.2k20136222




      52.2k20136222










      asked Oct 20 '14 at 2:14









      David FoersterDavid Foerster

      28.3k1365111




      28.3k1365111






















          4 Answers
          4






          active

          oldest

          votes


















          68





          +100









          Throughout this answer I'll assume, that a storage drive appears as a block device at the path /dev/sdc. To find the path of a storage drive in our current setup, use:





          • Gnome Disks Install Gnome Disks (formerly Gnome Disk Utility, a. k. a. palimpsest), if a GUI is available, or

          • on the terminal look at the output of lsblk and ls -l /dev/disk/by-id and try to find the right device by size, partitioning, manufacturer and model name.


          Basic check




          • only detects entirely unresponsive media

          • almost instantaneous (unless medium is spun down or broken)

          • safe

          • works on read-only media (e. g. CD, DVD, BluRay)


          Sometimes a storage medium simply refuses to work at all. It still appears as a block device to the kernel and in the disk manager, but its first sector holding the partition table is not readable. This can be verified easily with:



          sudo dd if=/dev/sdc of=/dev/null count=1


          If this command results in a message about an “Input/output error”, our drive is broken or otherwise fails to interact with the Linux kernel as expected. In the a former case, with a bit of luck, a data recovery specialist with an appropriately equipped lab can salvage its content. In the latter case, a different operating system is worth a try. (I've come across USB drives that work on Windows without special drivers, but not on Linux or OS X.)



          S.M.A.R.T. self-test




          • adjustable thoroughness

          • instantaneous to slow or slower (depends on thoroughness of the test)

          • safe

          • warns about likely failure in the near future


          Devices that support it, can be queried about their health through S.M.A.R.T. or instructed to perform integrity self-tests of different thoroughness. This is generally the best option, but usually only available on (non-ancient) hard disk and solid state drives. Most removable flash media don't support it.



          Further resources and instructions:




          • Answer about S.M.A.R.T. on this question

          • How can I check the SMART status of a drive on Ubuntu 14.04 through 16.10?


          Read-only check




          • only detects some flash media errors

          • quite reliable for hard disks

          • slow

          • safe

          • works on read-only media (e. g. CD, DVD, BluRay)


          To test the read integrity of the whole device without writing to it, we can use badblocks(8) like this:



          sudo badblocks -b 4096 -c 4096 -s /dev/sdc


          This operation can take a lot of time, especially if the storage drive actually is damaged. If the error count rises above zero, we'll know that there's a bad block. We can safely abort the operation at any moment (even forcefully like during a power failure), if we're not interested in the exact amount (and maybe location) of bad blocks. It's possible to abort automatically on error with the option -e 1.



          Note for advanced usage: if we want to reuse the output for e2fsck, we need to set the block size (-b) to that of the contained file system. We can also tweak the amount of data (-c, in blocks) tested at once to improve throughput; 16 MiB should be alright for most devices.



          Non-destructive read-write check




          • very thorough

          • slowest

          • quite safe (barring a power failure or intermittent kernel panic)


          Sometimes – especially with flash media – an error only occurs when trying to write. (This will not reliably discover (flash) media, that advertise a larger size, than they actually have; use Fight Flash Fraud instead.)




          • NEVER use this on a drive with mounted file systems! badblocks refuses to operate on those anyway, unless you force it.


          • Don't interrupt this operation forcefully! Ctrl+C (SIGINT/SIGTERM) and waiting for graceful premature termination is ok, but killall -9 badblocks (SIGKILL) isn't. Upon forceful termination badblocks cannot restore the original content of the currently tested block range and will leave it overwritten with junk data and possibly corrupt the file system.



          To use non-destructive read-write checks, add the -n option to the above badblocks command.



          Destructive read-write check




          • very thorough

          • slower

          • ERASES ALL DATA ON THE DRIVE


          As above, but without restoring the previous drive content after performing the write test, therefore it's a little faster. Since data is erased anyway, forceful termination remains without (additional) negative consequence.



          To use destructive read-write checks, add the -w option to the above badblocks command.






          share|improve this answer

































            19














            smartctl



            IMO smartctl is a better tool. You likely have to install it first



            sudo apt-get install smartmontools 


            Then



            sudo smartctl -a /dev/sda | less


            to print drive health data, attributes, and available test results. To quit less, type q. Alternatively



            sudo smartctl -H /dev/sda


            to just print health data.



            To begin a new short (a few minutes) or long (up to many hours) self test in background:



            sudo smartctl -t [short|long]


            GSsmartControl
            (home page) and Gnome Disks are graphical front ends if you prefer.



            See also




            • Smartmontools

            • http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

            • http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-to-get-smart-status-information-on-your-hard-drives/






            share|improve this answer





















            • 5





              Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

              – David Foerster
              Oct 20 '14 at 2:30











            • I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

              – nobar
              Nov 1 '15 at 5:26



















            9














            F3 (Fight Flash Fraud) is another option which should additionally detect fake flash drives (flash drives whose actual capacity is a fraction of advertised capacity):




            1. Insert your drive


            2. Install F3



              sudo apt-get install f3



            3. Write test data to the free space on the drive



              f3write /media/$USER/D871-DD7C/



            4. Read the test data



              f3read /media/$USER/D871-DD7C/



            Badblocks works well but it isn't designed for detecting fake flash drives and may not report any errors for them.






            share|improve this answer































              4














              You can test-read the entire disk, while showing a progress indicator:



              time sudo pv /dev/sdc >/dev/null


              Certain disk problems would manifest as reported I/O errors. This is a bit nicer than dd due to the progress indicator and because the command-line interface is a bit more standard and a bit less typo-prone. Note that pv is basically and enhanced version of cat. It may not be installed by default, but can be installed with sudo apt-get install pv.



              A similar approach is to read the disk with one of the several available tools that are specifically aware of disk I/O errors -- and have the feature of "trying hard to rescue data". Search for ddrescue in the package manager.






              share|improve this answer


























              • This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                – David Foerster
                Mar 19 '17 at 9:17













              • See also: ddrescueview

                – nobar
                Mar 1 '18 at 19:18











              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f539184%2fhow-do-i-check-the-integrity-of-a-storage-medium-hard-disk-or-flash-drive%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              68





              +100









              Throughout this answer I'll assume, that a storage drive appears as a block device at the path /dev/sdc. To find the path of a storage drive in our current setup, use:





              • Gnome Disks Install Gnome Disks (formerly Gnome Disk Utility, a. k. a. palimpsest), if a GUI is available, or

              • on the terminal look at the output of lsblk and ls -l /dev/disk/by-id and try to find the right device by size, partitioning, manufacturer and model name.


              Basic check




              • only detects entirely unresponsive media

              • almost instantaneous (unless medium is spun down or broken)

              • safe

              • works on read-only media (e. g. CD, DVD, BluRay)


              Sometimes a storage medium simply refuses to work at all. It still appears as a block device to the kernel and in the disk manager, but its first sector holding the partition table is not readable. This can be verified easily with:



              sudo dd if=/dev/sdc of=/dev/null count=1


              If this command results in a message about an “Input/output error”, our drive is broken or otherwise fails to interact with the Linux kernel as expected. In the a former case, with a bit of luck, a data recovery specialist with an appropriately equipped lab can salvage its content. In the latter case, a different operating system is worth a try. (I've come across USB drives that work on Windows without special drivers, but not on Linux or OS X.)



              S.M.A.R.T. self-test




              • adjustable thoroughness

              • instantaneous to slow or slower (depends on thoroughness of the test)

              • safe

              • warns about likely failure in the near future


              Devices that support it, can be queried about their health through S.M.A.R.T. or instructed to perform integrity self-tests of different thoroughness. This is generally the best option, but usually only available on (non-ancient) hard disk and solid state drives. Most removable flash media don't support it.



              Further resources and instructions:




              • Answer about S.M.A.R.T. on this question

              • How can I check the SMART status of a drive on Ubuntu 14.04 through 16.10?


              Read-only check




              • only detects some flash media errors

              • quite reliable for hard disks

              • slow

              • safe

              • works on read-only media (e. g. CD, DVD, BluRay)


              To test the read integrity of the whole device without writing to it, we can use badblocks(8) like this:



              sudo badblocks -b 4096 -c 4096 -s /dev/sdc


              This operation can take a lot of time, especially if the storage drive actually is damaged. If the error count rises above zero, we'll know that there's a bad block. We can safely abort the operation at any moment (even forcefully like during a power failure), if we're not interested in the exact amount (and maybe location) of bad blocks. It's possible to abort automatically on error with the option -e 1.



              Note for advanced usage: if we want to reuse the output for e2fsck, we need to set the block size (-b) to that of the contained file system. We can also tweak the amount of data (-c, in blocks) tested at once to improve throughput; 16 MiB should be alright for most devices.



              Non-destructive read-write check




              • very thorough

              • slowest

              • quite safe (barring a power failure or intermittent kernel panic)


              Sometimes – especially with flash media – an error only occurs when trying to write. (This will not reliably discover (flash) media, that advertise a larger size, than they actually have; use Fight Flash Fraud instead.)




              • NEVER use this on a drive with mounted file systems! badblocks refuses to operate on those anyway, unless you force it.


              • Don't interrupt this operation forcefully! Ctrl+C (SIGINT/SIGTERM) and waiting for graceful premature termination is ok, but killall -9 badblocks (SIGKILL) isn't. Upon forceful termination badblocks cannot restore the original content of the currently tested block range and will leave it overwritten with junk data and possibly corrupt the file system.



              To use non-destructive read-write checks, add the -n option to the above badblocks command.



              Destructive read-write check




              • very thorough

              • slower

              • ERASES ALL DATA ON THE DRIVE


              As above, but without restoring the previous drive content after performing the write test, therefore it's a little faster. Since data is erased anyway, forceful termination remains without (additional) negative consequence.



              To use destructive read-write checks, add the -w option to the above badblocks command.






              share|improve this answer






























                68





                +100









                Throughout this answer I'll assume, that a storage drive appears as a block device at the path /dev/sdc. To find the path of a storage drive in our current setup, use:





                • Gnome Disks Install Gnome Disks (formerly Gnome Disk Utility, a. k. a. palimpsest), if a GUI is available, or

                • on the terminal look at the output of lsblk and ls -l /dev/disk/by-id and try to find the right device by size, partitioning, manufacturer and model name.


                Basic check




                • only detects entirely unresponsive media

                • almost instantaneous (unless medium is spun down or broken)

                • safe

                • works on read-only media (e. g. CD, DVD, BluRay)


                Sometimes a storage medium simply refuses to work at all. It still appears as a block device to the kernel and in the disk manager, but its first sector holding the partition table is not readable. This can be verified easily with:



                sudo dd if=/dev/sdc of=/dev/null count=1


                If this command results in a message about an “Input/output error”, our drive is broken or otherwise fails to interact with the Linux kernel as expected. In the a former case, with a bit of luck, a data recovery specialist with an appropriately equipped lab can salvage its content. In the latter case, a different operating system is worth a try. (I've come across USB drives that work on Windows without special drivers, but not on Linux or OS X.)



                S.M.A.R.T. self-test




                • adjustable thoroughness

                • instantaneous to slow or slower (depends on thoroughness of the test)

                • safe

                • warns about likely failure in the near future


                Devices that support it, can be queried about their health through S.M.A.R.T. or instructed to perform integrity self-tests of different thoroughness. This is generally the best option, but usually only available on (non-ancient) hard disk and solid state drives. Most removable flash media don't support it.



                Further resources and instructions:




                • Answer about S.M.A.R.T. on this question

                • How can I check the SMART status of a drive on Ubuntu 14.04 through 16.10?


                Read-only check




                • only detects some flash media errors

                • quite reliable for hard disks

                • slow

                • safe

                • works on read-only media (e. g. CD, DVD, BluRay)


                To test the read integrity of the whole device without writing to it, we can use badblocks(8) like this:



                sudo badblocks -b 4096 -c 4096 -s /dev/sdc


                This operation can take a lot of time, especially if the storage drive actually is damaged. If the error count rises above zero, we'll know that there's a bad block. We can safely abort the operation at any moment (even forcefully like during a power failure), if we're not interested in the exact amount (and maybe location) of bad blocks. It's possible to abort automatically on error with the option -e 1.



                Note for advanced usage: if we want to reuse the output for e2fsck, we need to set the block size (-b) to that of the contained file system. We can also tweak the amount of data (-c, in blocks) tested at once to improve throughput; 16 MiB should be alright for most devices.



                Non-destructive read-write check




                • very thorough

                • slowest

                • quite safe (barring a power failure or intermittent kernel panic)


                Sometimes – especially with flash media – an error only occurs when trying to write. (This will not reliably discover (flash) media, that advertise a larger size, than they actually have; use Fight Flash Fraud instead.)




                • NEVER use this on a drive with mounted file systems! badblocks refuses to operate on those anyway, unless you force it.


                • Don't interrupt this operation forcefully! Ctrl+C (SIGINT/SIGTERM) and waiting for graceful premature termination is ok, but killall -9 badblocks (SIGKILL) isn't. Upon forceful termination badblocks cannot restore the original content of the currently tested block range and will leave it overwritten with junk data and possibly corrupt the file system.



                To use non-destructive read-write checks, add the -n option to the above badblocks command.



                Destructive read-write check




                • very thorough

                • slower

                • ERASES ALL DATA ON THE DRIVE


                As above, but without restoring the previous drive content after performing the write test, therefore it's a little faster. Since data is erased anyway, forceful termination remains without (additional) negative consequence.



                To use destructive read-write checks, add the -w option to the above badblocks command.






                share|improve this answer




























                  68





                  +100







                  68





                  +100



                  68




                  +100





                  Throughout this answer I'll assume, that a storage drive appears as a block device at the path /dev/sdc. To find the path of a storage drive in our current setup, use:





                  • Gnome Disks Install Gnome Disks (formerly Gnome Disk Utility, a. k. a. palimpsest), if a GUI is available, or

                  • on the terminal look at the output of lsblk and ls -l /dev/disk/by-id and try to find the right device by size, partitioning, manufacturer and model name.


                  Basic check




                  • only detects entirely unresponsive media

                  • almost instantaneous (unless medium is spun down or broken)

                  • safe

                  • works on read-only media (e. g. CD, DVD, BluRay)


                  Sometimes a storage medium simply refuses to work at all. It still appears as a block device to the kernel and in the disk manager, but its first sector holding the partition table is not readable. This can be verified easily with:



                  sudo dd if=/dev/sdc of=/dev/null count=1


                  If this command results in a message about an “Input/output error”, our drive is broken or otherwise fails to interact with the Linux kernel as expected. In the a former case, with a bit of luck, a data recovery specialist with an appropriately equipped lab can salvage its content. In the latter case, a different operating system is worth a try. (I've come across USB drives that work on Windows without special drivers, but not on Linux or OS X.)



                  S.M.A.R.T. self-test




                  • adjustable thoroughness

                  • instantaneous to slow or slower (depends on thoroughness of the test)

                  • safe

                  • warns about likely failure in the near future


                  Devices that support it, can be queried about their health through S.M.A.R.T. or instructed to perform integrity self-tests of different thoroughness. This is generally the best option, but usually only available on (non-ancient) hard disk and solid state drives. Most removable flash media don't support it.



                  Further resources and instructions:




                  • Answer about S.M.A.R.T. on this question

                  • How can I check the SMART status of a drive on Ubuntu 14.04 through 16.10?


                  Read-only check




                  • only detects some flash media errors

                  • quite reliable for hard disks

                  • slow

                  • safe

                  • works on read-only media (e. g. CD, DVD, BluRay)


                  To test the read integrity of the whole device without writing to it, we can use badblocks(8) like this:



                  sudo badblocks -b 4096 -c 4096 -s /dev/sdc


                  This operation can take a lot of time, especially if the storage drive actually is damaged. If the error count rises above zero, we'll know that there's a bad block. We can safely abort the operation at any moment (even forcefully like during a power failure), if we're not interested in the exact amount (and maybe location) of bad blocks. It's possible to abort automatically on error with the option -e 1.



                  Note for advanced usage: if we want to reuse the output for e2fsck, we need to set the block size (-b) to that of the contained file system. We can also tweak the amount of data (-c, in blocks) tested at once to improve throughput; 16 MiB should be alright for most devices.



                  Non-destructive read-write check




                  • very thorough

                  • slowest

                  • quite safe (barring a power failure or intermittent kernel panic)


                  Sometimes – especially with flash media – an error only occurs when trying to write. (This will not reliably discover (flash) media, that advertise a larger size, than they actually have; use Fight Flash Fraud instead.)




                  • NEVER use this on a drive with mounted file systems! badblocks refuses to operate on those anyway, unless you force it.


                  • Don't interrupt this operation forcefully! Ctrl+C (SIGINT/SIGTERM) and waiting for graceful premature termination is ok, but killall -9 badblocks (SIGKILL) isn't. Upon forceful termination badblocks cannot restore the original content of the currently tested block range and will leave it overwritten with junk data and possibly corrupt the file system.



                  To use non-destructive read-write checks, add the -n option to the above badblocks command.



                  Destructive read-write check




                  • very thorough

                  • slower

                  • ERASES ALL DATA ON THE DRIVE


                  As above, but without restoring the previous drive content after performing the write test, therefore it's a little faster. Since data is erased anyway, forceful termination remains without (additional) negative consequence.



                  To use destructive read-write checks, add the -w option to the above badblocks command.






                  share|improve this answer















                  Throughout this answer I'll assume, that a storage drive appears as a block device at the path /dev/sdc. To find the path of a storage drive in our current setup, use:





                  • Gnome Disks Install Gnome Disks (formerly Gnome Disk Utility, a. k. a. palimpsest), if a GUI is available, or

                  • on the terminal look at the output of lsblk and ls -l /dev/disk/by-id and try to find the right device by size, partitioning, manufacturer and model name.


                  Basic check




                  • only detects entirely unresponsive media

                  • almost instantaneous (unless medium is spun down or broken)

                  • safe

                  • works on read-only media (e. g. CD, DVD, BluRay)


                  Sometimes a storage medium simply refuses to work at all. It still appears as a block device to the kernel and in the disk manager, but its first sector holding the partition table is not readable. This can be verified easily with:



                  sudo dd if=/dev/sdc of=/dev/null count=1


                  If this command results in a message about an “Input/output error”, our drive is broken or otherwise fails to interact with the Linux kernel as expected. In the a former case, with a bit of luck, a data recovery specialist with an appropriately equipped lab can salvage its content. In the latter case, a different operating system is worth a try. (I've come across USB drives that work on Windows without special drivers, but not on Linux or OS X.)



                  S.M.A.R.T. self-test




                  • adjustable thoroughness

                  • instantaneous to slow or slower (depends on thoroughness of the test)

                  • safe

                  • warns about likely failure in the near future


                  Devices that support it, can be queried about their health through S.M.A.R.T. or instructed to perform integrity self-tests of different thoroughness. This is generally the best option, but usually only available on (non-ancient) hard disk and solid state drives. Most removable flash media don't support it.



                  Further resources and instructions:




                  • Answer about S.M.A.R.T. on this question

                  • How can I check the SMART status of a drive on Ubuntu 14.04 through 16.10?


                  Read-only check




                  • only detects some flash media errors

                  • quite reliable for hard disks

                  • slow

                  • safe

                  • works on read-only media (e. g. CD, DVD, BluRay)


                  To test the read integrity of the whole device without writing to it, we can use badblocks(8) like this:



                  sudo badblocks -b 4096 -c 4096 -s /dev/sdc


                  This operation can take a lot of time, especially if the storage drive actually is damaged. If the error count rises above zero, we'll know that there's a bad block. We can safely abort the operation at any moment (even forcefully like during a power failure), if we're not interested in the exact amount (and maybe location) of bad blocks. It's possible to abort automatically on error with the option -e 1.



                  Note for advanced usage: if we want to reuse the output for e2fsck, we need to set the block size (-b) to that of the contained file system. We can also tweak the amount of data (-c, in blocks) tested at once to improve throughput; 16 MiB should be alright for most devices.



                  Non-destructive read-write check




                  • very thorough

                  • slowest

                  • quite safe (barring a power failure or intermittent kernel panic)


                  Sometimes – especially with flash media – an error only occurs when trying to write. (This will not reliably discover (flash) media, that advertise a larger size, than they actually have; use Fight Flash Fraud instead.)




                  • NEVER use this on a drive with mounted file systems! badblocks refuses to operate on those anyway, unless you force it.


                  • Don't interrupt this operation forcefully! Ctrl+C (SIGINT/SIGTERM) and waiting for graceful premature termination is ok, but killall -9 badblocks (SIGKILL) isn't. Upon forceful termination badblocks cannot restore the original content of the currently tested block range and will leave it overwritten with junk data and possibly corrupt the file system.



                  To use non-destructive read-write checks, add the -n option to the above badblocks command.



                  Destructive read-write check




                  • very thorough

                  • slower

                  • ERASES ALL DATA ON THE DRIVE


                  As above, but without restoring the previous drive content after performing the write test, therefore it's a little faster. Since data is erased anyway, forceful termination remains without (additional) negative consequence.



                  To use destructive read-write checks, add the -w option to the above badblocks command.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 11 '17 at 19:02









                  Community

                  1




                  1










                  answered Oct 20 '14 at 2:14









                  David FoersterDavid Foerster

                  28.3k1365111




                  28.3k1365111

























                      19














                      smartctl



                      IMO smartctl is a better tool. You likely have to install it first



                      sudo apt-get install smartmontools 


                      Then



                      sudo smartctl -a /dev/sda | less


                      to print drive health data, attributes, and available test results. To quit less, type q. Alternatively



                      sudo smartctl -H /dev/sda


                      to just print health data.



                      To begin a new short (a few minutes) or long (up to many hours) self test in background:



                      sudo smartctl -t [short|long]


                      GSsmartControl
                      (home page) and Gnome Disks are graphical front ends if you prefer.



                      See also




                      • Smartmontools

                      • http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

                      • http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-to-get-smart-status-information-on-your-hard-drives/






                      share|improve this answer





















                      • 5





                        Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                        – David Foerster
                        Oct 20 '14 at 2:30











                      • I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                        – nobar
                        Nov 1 '15 at 5:26
















                      19














                      smartctl



                      IMO smartctl is a better tool. You likely have to install it first



                      sudo apt-get install smartmontools 


                      Then



                      sudo smartctl -a /dev/sda | less


                      to print drive health data, attributes, and available test results. To quit less, type q. Alternatively



                      sudo smartctl -H /dev/sda


                      to just print health data.



                      To begin a new short (a few minutes) or long (up to many hours) self test in background:



                      sudo smartctl -t [short|long]


                      GSsmartControl
                      (home page) and Gnome Disks are graphical front ends if you prefer.



                      See also




                      • Smartmontools

                      • http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

                      • http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-to-get-smart-status-information-on-your-hard-drives/






                      share|improve this answer





















                      • 5





                        Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                        – David Foerster
                        Oct 20 '14 at 2:30











                      • I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                        – nobar
                        Nov 1 '15 at 5:26














                      19












                      19








                      19







                      smartctl



                      IMO smartctl is a better tool. You likely have to install it first



                      sudo apt-get install smartmontools 


                      Then



                      sudo smartctl -a /dev/sda | less


                      to print drive health data, attributes, and available test results. To quit less, type q. Alternatively



                      sudo smartctl -H /dev/sda


                      to just print health data.



                      To begin a new short (a few minutes) or long (up to many hours) self test in background:



                      sudo smartctl -t [short|long]


                      GSsmartControl
                      (home page) and Gnome Disks are graphical front ends if you prefer.



                      See also




                      • Smartmontools

                      • http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

                      • http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-to-get-smart-status-information-on-your-hard-drives/






                      share|improve this answer















                      smartctl



                      IMO smartctl is a better tool. You likely have to install it first



                      sudo apt-get install smartmontools 


                      Then



                      sudo smartctl -a /dev/sda | less


                      to print drive health data, attributes, and available test results. To quit less, type q. Alternatively



                      sudo smartctl -H /dev/sda


                      to just print health data.



                      To begin a new short (a few minutes) or long (up to many hours) self test in background:



                      sudo smartctl -t [short|long]


                      GSsmartControl
                      (home page) and Gnome Disks are graphical front ends if you prefer.



                      See also




                      • Smartmontools

                      • http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

                      • http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-to-get-smart-status-information-on-your-hard-drives/







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 8 hours ago









                      Pablo Bianchi

                      2,75821533




                      2,75821533










                      answered Oct 20 '14 at 2:26









                      PantherPanther

                      79.3k14157259




                      79.3k14157259








                      • 5





                        Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                        – David Foerster
                        Oct 20 '14 at 2:30











                      • I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                        – nobar
                        Nov 1 '15 at 5:26














                      • 5





                        Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                        – David Foerster
                        Oct 20 '14 at 2:30











                      • I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                        – nobar
                        Nov 1 '15 at 5:26








                      5




                      5





                      Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                      – David Foerster
                      Oct 20 '14 at 2:30





                      Great solution, if the device supports SMART. Many (cheap) removable flash drives and very old hard drives don't.

                      – David Foerster
                      Oct 20 '14 at 2:30













                      I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                      – nobar
                      Nov 1 '15 at 5:26





                      I was initially stumped when smartctl reported: "Unknown USB bridge", "Please specify device type with the -d option". I found the data I needed at: smartmontools.org/wiki/Supported_USB-Devices.

                      – nobar
                      Nov 1 '15 at 5:26











                      9














                      F3 (Fight Flash Fraud) is another option which should additionally detect fake flash drives (flash drives whose actual capacity is a fraction of advertised capacity):




                      1. Insert your drive


                      2. Install F3



                        sudo apt-get install f3



                      3. Write test data to the free space on the drive



                        f3write /media/$USER/D871-DD7C/



                      4. Read the test data



                        f3read /media/$USER/D871-DD7C/



                      Badblocks works well but it isn't designed for detecting fake flash drives and may not report any errors for them.






                      share|improve this answer




























                        9














                        F3 (Fight Flash Fraud) is another option which should additionally detect fake flash drives (flash drives whose actual capacity is a fraction of advertised capacity):




                        1. Insert your drive


                        2. Install F3



                          sudo apt-get install f3



                        3. Write test data to the free space on the drive



                          f3write /media/$USER/D871-DD7C/



                        4. Read the test data



                          f3read /media/$USER/D871-DD7C/



                        Badblocks works well but it isn't designed for detecting fake flash drives and may not report any errors for them.






                        share|improve this answer


























                          9












                          9








                          9







                          F3 (Fight Flash Fraud) is another option which should additionally detect fake flash drives (flash drives whose actual capacity is a fraction of advertised capacity):




                          1. Insert your drive


                          2. Install F3



                            sudo apt-get install f3



                          3. Write test data to the free space on the drive



                            f3write /media/$USER/D871-DD7C/



                          4. Read the test data



                            f3read /media/$USER/D871-DD7C/



                          Badblocks works well but it isn't designed for detecting fake flash drives and may not report any errors for them.






                          share|improve this answer













                          F3 (Fight Flash Fraud) is another option which should additionally detect fake flash drives (flash drives whose actual capacity is a fraction of advertised capacity):




                          1. Insert your drive


                          2. Install F3



                            sudo apt-get install f3



                          3. Write test data to the free space on the drive



                            f3write /media/$USER/D871-DD7C/



                          4. Read the test data



                            f3read /media/$USER/D871-DD7C/



                          Badblocks works well but it isn't designed for detecting fake flash drives and may not report any errors for them.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 28 '15 at 19:48









                          bmaupinbmaupin

                          2,5212347




                          2,5212347























                              4














                              You can test-read the entire disk, while showing a progress indicator:



                              time sudo pv /dev/sdc >/dev/null


                              Certain disk problems would manifest as reported I/O errors. This is a bit nicer than dd due to the progress indicator and because the command-line interface is a bit more standard and a bit less typo-prone. Note that pv is basically and enhanced version of cat. It may not be installed by default, but can be installed with sudo apt-get install pv.



                              A similar approach is to read the disk with one of the several available tools that are specifically aware of disk I/O errors -- and have the feature of "trying hard to rescue data". Search for ddrescue in the package manager.






                              share|improve this answer


























                              • This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                                – David Foerster
                                Mar 19 '17 at 9:17













                              • See also: ddrescueview

                                – nobar
                                Mar 1 '18 at 19:18
















                              4














                              You can test-read the entire disk, while showing a progress indicator:



                              time sudo pv /dev/sdc >/dev/null


                              Certain disk problems would manifest as reported I/O errors. This is a bit nicer than dd due to the progress indicator and because the command-line interface is a bit more standard and a bit less typo-prone. Note that pv is basically and enhanced version of cat. It may not be installed by default, but can be installed with sudo apt-get install pv.



                              A similar approach is to read the disk with one of the several available tools that are specifically aware of disk I/O errors -- and have the feature of "trying hard to rescue data". Search for ddrescue in the package manager.






                              share|improve this answer


























                              • This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                                – David Foerster
                                Mar 19 '17 at 9:17













                              • See also: ddrescueview

                                – nobar
                                Mar 1 '18 at 19:18














                              4












                              4








                              4







                              You can test-read the entire disk, while showing a progress indicator:



                              time sudo pv /dev/sdc >/dev/null


                              Certain disk problems would manifest as reported I/O errors. This is a bit nicer than dd due to the progress indicator and because the command-line interface is a bit more standard and a bit less typo-prone. Note that pv is basically and enhanced version of cat. It may not be installed by default, but can be installed with sudo apt-get install pv.



                              A similar approach is to read the disk with one of the several available tools that are specifically aware of disk I/O errors -- and have the feature of "trying hard to rescue data". Search for ddrescue in the package manager.






                              share|improve this answer















                              You can test-read the entire disk, while showing a progress indicator:



                              time sudo pv /dev/sdc >/dev/null


                              Certain disk problems would manifest as reported I/O errors. This is a bit nicer than dd due to the progress indicator and because the command-line interface is a bit more standard and a bit less typo-prone. Note that pv is basically and enhanced version of cat. It may not be installed by default, but can be installed with sudo apt-get install pv.



                              A similar approach is to read the disk with one of the several available tools that are specifically aware of disk I/O errors -- and have the feature of "trying hard to rescue data". Search for ddrescue in the package manager.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Apr 13 '17 at 12:14









                              Community

                              1




                              1










                              answered Nov 1 '15 at 6:44









                              nobarnobar

                              1,52121427




                              1,52121427













                              • This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                                – David Foerster
                                Mar 19 '17 at 9:17













                              • See also: ddrescueview

                                – nobar
                                Mar 1 '18 at 19:18



















                              • This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                                – David Foerster
                                Mar 19 '17 at 9:17













                              • See also: ddrescueview

                                – nobar
                                Mar 1 '18 at 19:18

















                              This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                              – David Foerster
                              Mar 19 '17 at 9:17







                              This will not detect issues that appear only during write access and it won't report the affected region of the storage medium that one would need to fix or work around the issue. dd count=1 is also pretty fast unless the storage medium is utterly broken (or unsupported).

                              – David Foerster
                              Mar 19 '17 at 9:17















                              See also: ddrescueview

                              – nobar
                              Mar 1 '18 at 19:18





                              See also: ddrescueview

                              – nobar
                              Mar 1 '18 at 19:18


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f539184%2fhow-do-i-check-the-integrity-of-a-storage-medium-hard-disk-or-flash-drive%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How did Captain America manage to do this?

                              迪纳利

                              南乌拉尔铁路局