Git Product home page Git Product logo

stressdrive's Introduction

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

Installing

macOS

using macports

This will probably need sudo:

port install stressdrive

Building

macOS

using homebrew

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 -lcrypto -framework IOKit -framework CoreServices -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

using macports

Same commands for macports:

port install openssl

xcodebuild PREFIX=/opt/local SEARCH_PREFIX=/opt/local

gcc stressdrive.c -o stressdrive -lcrypto -framework IOKit -framework CoreServices -I/opt/local/include -L/opt/local/lib

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.4: 2023-11-23 download

  • [NEW] Store a checksum every 1GB, allowing faster reporting of drive failure. It requires 20 bytes per gigabyte, so 80K for a 4TB drive. (Ivan Kuchin)

  • [NEW] Apply an exclusive advisory lock on device after opening, making running two instances on the same drive impossible (Ivan Kuchin)

  • [DOC] Add instructions for installing using macports (Ivan Kuchin)

  • [FIX] Include sys/file.h missing at least on ubuntu (Ivan Kuchin)

  • [FIX] Upgrade checkCount to uint64_t to avoid precision loss warning (rentzsch)

  • [DEV] Refactor xcode project to allow different prefix, update instructions for macOS (Ivan Kuchin)

  • [DEV] Mention sleep in idle assertion message and variable name (Ivan Kuchin)

  • [FIX] Xcode v12.5, Homebrew on Apple Silicon (rentzsch)

  • [DEV] Xcode 15 bottoms out at 10.13 as a minimum deployment target (rentzsch)

  • [DOC] Use archive.org link for 404 storagemojo.com article (rentzsch)

v1.3.2: 2020-07-05 download

  • [CHANGE] Target oldest supported macOS (10.6). (rentzsch)

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.

stressdrive's People

Contributors

rentzsch avatar toy avatar everythingsolution avatar boredzo avatar thunfischbrot avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.