Code Monkey home page Code Monkey logo

disktest's Introduction

disktest - Tester for Solid State Disk (SSD), Non-Volatile Memory Storage (NVMe), Hard Disk (HDD), USB Stick, SD-Card, etc...

Homepage

Git repository

Github repository

crates.io site

Disktest is a tool to check Solid State Disks, Non-Volatile Memory Storage, Hard Disks, USB sticks, SD cards or other storage media for errors.

It does so by writing a pseudo random sequence to the device and then reading it back and verifying it to the same pseudo random sequence.

This tool can be used to:

  • Check disks for hardware errors (e.g. platter errors, flash errors, etc...).
  • Overwrite storage media with a cryptographically strong pseudo random stream. This can either be used to delete existing data on the disk, or to prepare the disk for encryption.
  • Test for tampered media that pretend to have more storage area than they physically actually have. Sometimes such media are sold by fraudulent sellers for cheap prices.
  • Measure read and write speed.
  • ... probably lots of other tasks.

The random number stream is generated by the following algorithm:

OUTPUT_DATA := CHACHA20(PBKDF2(SEED | THREAD_ID | ROUND_ID))

If more than one thread is used, then each thread generates such a random number stream, which are then interleaved in an alternating pattern.

Security

The default algorithm ChaCha20 is a cryptographically strong random number generator. That means if the seed is kept secret, then the random sequence cannot be predicted or reconstructed by anybody else.

See option --seed under --help for more details.

Linux example

The following disktest invocation will write a secure sequence to the disk device /dev/sdc and subsequently read back and verify the sequence from the disk device.

disktest --write --verify -j0 /dev/sdc

For NVMe:

disktest --write --verify -j0 /dev/nvme0n1

For SD / MMC:

disktest --write --verify -j0 /dev/mmcblk0

WARNING: This will irrevocably overwrite all data on the storage device! Be absolutely certain that the device path is correct before starting the command. Your data cannot be recovered.

You probably need root permissions to write to raw disk devices (/dev/sdX, /dev/nvmeXn1 or /dev/mmcblkX).

The target device does not have to be an actual hardware device node. It can be any file path on any file system. For example you can mount an USB stick file system and write to a file on that file system. However, please note that this leaves a couple minor untested spots in the USB stick's memory, which are reserved to the file system. Also see the Windows section below.

Windows example

On Windows disktest can write to any file on any mounted storage media or raw disks.

If your storage media under test is drive E, then the following command would write a test file on drive E and verify it:

disktest --write --verify -j0 E:\testfile.img

But note that testing on filesystem level like above does not test the full device. It will omit the disk areas the filesystem uses internally. Therefore, you may want to write to the raw disk E with the Windows raw drive notation as follows:

disktest --write --verify -j0 \\.\E:

or

disktest --write --verify -j0 \\.\PhysicalDrive2

Doing so will completely wipe all data (including the filesystem) on this disk.

Always make sure that you selected the correct drive. Especially in the \\\\.\PhysicalDriveX notation it is extremely easy to overwrite the wrong drive by accident. Therefore, the \\\\.\X: (where X is the drive letter) notation is preferred.

Dependencies

  • Rust 1.65.0 or later.
  • Crate dependencies will automatically be downloaded by cargo.

Installing from crates.io

Download the latest version of disktest from crates.io and install it to $HOME/.cargo/bin:

cargo install disktest

Installing from source package

Build disktest and install it to $HOME/.cargo/bin:

cd path/to/source/package
cargo install --path .

Running from source package without installing

Build and run disktest in place without installing it:

cd path/to/source/package
cargo run --release --  DISKTEST_OPTIONS_HERE

See below for a description of the available disktest options.

Disktest command line options

Please run either of the following commands to show more information about the available command line options.

cargo run --release -- --help
disktest --help

Speed

The following table shows some example speed measurements of disktest in various operation mode on different hardware.

These speed tests don't write to an actual disk, but only to the /dev/null device, which is a device that does nothing. So these speed test results do not include the speed limits of any actual disk hardware.

Command Algorithm Hardware Data rate written
disktest -j12 -ACHACHA20 -w /dev/null ChaCha20 AMD Ryzen 5 5500U; 6x2 cores 8.1 GiB/s
disktest -j12 -ACHACHA12 -w /dev/null ChaCha12 AMD Ryzen 5 5500U; 6x2 cores 8.2 GiB/s
disktest -j12 -ACHACHA8 -w /dev/null ChaCha8 AMD Ryzen 5 5500U; 6x2 cores 8.3 GiB/s
disktest -j12 -ACRC -w /dev/null CRC AMD Ryzen 5 5500U; 6x2 cores 8.4 GiB/s
disktest -j4 -ACHACHA20 -w /dev/null ChaCha20 Intel i5-3320M; 2x2 cores 2.1 GiB/s
disktest -j4 -ACHACHA12 -w /dev/null ChaCha12 Intel i5-3320M; 2x2 cores 3.2 GiB/s
disktest -j4 -ACHACHA8 -w /dev/null ChaCha8 Intel i5-3320M; 2x2 cores 4.4 GiB/s
disktest -j4 -ACRC -w /dev/null CRC Intel i5-3320M; 2x2 cores 7.5 GiB/s
disktest -j4 -ACHACHA20 -w /dev/null ChaCha20 Raspberry Pi 4; 4 cores 1.5 GHz 420 MiB/s
disktest -j4 -ACHACHA12 -w /dev/null ChaCha12 Raspberry Pi 4; 4 cores 1.5 GHz 670 MiB/s
disktest -j4 -ACHACHA8 -w /dev/null ChaCha8 Raspberry Pi 4; 4 cores 1.5 GHz 920 MiB/s
disktest -j4 -ACRC -w /dev/null CRC Raspberry Pi 4; 4 cores 1.5 GHz 2.5 GiB/s

The read data rates are similar, because the algorithm used is exactly the same.

License

Copyright (c) 2020-2024 Michael Büsch [email protected]

Licensed under the Apache License version 2.0 or the MIT license, at your option.

disktest's People

Contributors

mbuesch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

disktest's Issues

Feature enhancement possibly ?

This looks interesting, https://github.com/bingmann/disk-filltest?tab=readme-ov-file.
I has an -U mode which may be an idea to incorporate in to your app (https://panthema.net/2013/disk-filltest/) which "The only option requiring more explanation is -U. In this mode, the tool will create the files random-######## as usual, but will immediately unlink() them from the file system (the directory stays empty). On Linux this is possible, because the tool can keep the file descriptors open and perform the usual write/read/verify sequence. The mode is very useful for batch checking, because the system will automatically free the used disk space when the program finishes, whether successfully or with an error!"

I prefer your app as it's rust. Just an idea. I would also apprecaite any pro's and con's of each app as they both seem to do a very similar job.

Release it as a library

It would be nice if this could be released as a library and the library itself provides the binary.
This would help developers that want to have such functionality on their software.

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.