Skip to content

Latest commit

 

History

History
110 lines (66 loc) · 5.67 KB

README.markdown

File metadata and controls

110 lines (66 loc) · 5.67 KB

About

stressdrive is a macOS and Linux command-line tool meant to verify correct operation of a drive. It does so by filling a drive up with random data and ensuring all the data can be correctly read back.

It was written to verify correct operation of de-duping SSDs, but it can be used with normal HDDs or any rewritable block storage device.

DANGER: stressdrive will overwrite, without warning, all data on the given drive. Be sure to double-check the drive you're aiming it at (diskutil list or Disk Utility.app > Select Drive > Info > Disk Identifier).

Usage

sudo ./stressdrive /dev/rdiskN

Run Only Against Entire, Unmounted, Physical Devices

stressdrive should always be run against entire unmounted physical devices.

Practically: your device path should always be in the form of /dev/rdiskX (not /dev/rdiskXsX). stressdrive's results can only be trusted if it was allowed to fill the entire device to the device's advertised information-theoretic maximum.

Imagine pointing stressdrive at just a logical partition. If the drive failed during the test it's possible to get back a clean read of the random data just written, while a block outside the device's partition is no longer correct. That would not be an accurate test result.

Sample Run

Here's stressdrive running against a 2 GB USB Flash drive:

$ sudo ./stressdrive /dev/rdisk999
Password:
disk block size: 512
disk block count: 3948424
buffer size: 8388608
succesfully created no idle assertion
writing random data to /dev/rdisk999
writing 100.0% (3948424 of 3948424) 00:03:54
6519594c7bf64d5e4e087cfbc5ba6324d25e8c0d <= SHA-1 of written data
verifying written data
reading 100.0% (3948424 of 3948424) 00:01:24
6519594c7bf64d5e4e087cfbc5ba6324d25e8c0d <= SHA-1 of read data
SUCCESS
succesfully released no idle assertion

Building

macOS

First, you'll need OpenSSL, which you should install via homebrew:

brew install openssl

Then you can just:

xcodebuild

Or compile it directly:

gcc stressdrive.c -o stressdrive -framework IOKit -framework CoreServices -I/usr/local/opt/openssl/include /usr/local/opt/openssl/lib/libcrypto.a

Ubuntu

sudo apt-get install libssl-dev # You will need openssl headers

gcc stressdrive.c -o stressdrive -std=c99 -lcrypto

FAQ

"How is this better than Disk Utility's 'Zero Out Data'?"

Some SSD's de-duplicate stored blocks. For these "filling" it with zeros if actually just modifying one or two actual mapping blocks over and over again. It's not a real test of the SSD's hardware.

"How is this better than Disk Utility's '7-Pass Erase'?"

stressdrive only overwrites the drive with data once (so it's 7x faster) and then verifies all the data is correctly read back (which Disk Utility doesn't do at all).

Jens Ayton informs me 7-Pass Erase uses fixed patterns, so de-duping may be an issue there as well.

"Pshaw! I could do this with dd, /dev/random & shasum!"

Indeed you could. I prefer a minimal focused tool whose operation is fixed, its source simple+readable and offers good built-in progress reporting.

Version History

v1.3.1: 2020-07-04 download

v1.3: 2018-02-19

  • [NEW] Display speed alongside progress. (Ivan Kuchin)

v1.2.1: 2018-01-04 download

  • [FIX] Statically link libcrypto. (rentzsch)

v1.2: 2018-01-03 download

  • [NEW] Linux support. (Ivan Kuchin)
  • [NEW] Better progress display: elapsed time and ETA. (Ivan Kuchin)
  • [NEW] Use AES 128 CBC with a random key and initialization vector as a much faster source of data sans fixed patterns. (Ivan Kuchin)
  • [NEW] Don't allow the Mac to idle (sleep) while running. (Ivan Kuchin)
  • [NEW] Print version alongside usage. (rentzsch)
  • [CHANGE] Remove speed scaling in favor of a simpler and as fast fixed 8MB copy buffer. (Ivan Kuchin)
  • [FIX] Possible overflow in speedscale. (Doug Russell)
  • [FIX] Xcode project references Homebrew's OpenSSL in a non-version-specific way (so it doesn't break on every update). (rentzsch)

v1.1: 2011-11-17 download

  • [NEW] Speed scaling, which increases the copy buffer to the maximum that's still evenly divisible by the drive's capacity. (rentzsch)

v1.0: 2011-11-16 download

  • Initial release.