Original repository at: https://git.bues.ch/git/disktest.git

Michael Buesch acc03edab1 Add seed generator 1 day ago
.cargo 0d23eb9b6c Add build optimization 1 month ago
maintenance ec521cbf8b makerelease: default_archives is not required. 2 weeks ago
src acc03edab1 Add seed generator 7 hours ago
.gitignore cd17aa4d7b Generate markdown documentation from rst 2 weeks ago
COPYING 2955a0f39d Initial commit 1 month ago
Cargo.toml db1486fbbb Add fast CRC based generator 4 days ago
README.rst acc03edab1 Add seed generator 7 hours ago

README.rst

disktest - Hard Disk (HDD), Solid State Disk (SSD), USB Stick, SD-Card tester
=============================================================================

`https://bues.ch/h/disktest `_

Disktest is a tool to check Hard Disks, Solid State Disks, USB sticks, SD cards or similar 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 expected 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.
* ... probably lots of other tasks.

The random number stream is generated by the following algorithm:
::

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

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


Security
========

The default algorithm `ChaCha20 `_ is a cryptographically strong random number generator.

That means if the a custom seed is used (`--seed` or `--gen-seed`) and that seed is kept secret, then the random sequence cannot be predicted or reconstructed by anybody else.

Please note that if the option `--seed` or `--gen-seed` is omitted, then the random number stream will *not* be secure. In that case a hardcoded seed will be used, that is the same for everybody using disktest.

See option `--seed` and `--gen-seed` under `--help` for more details.


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.

.. code:: sh

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

*WARNING*: This will irrevocably overwrite all data on the disk `/dev/sdc`! Be absolutely certain that the device is correct before starting the command. Your data cannot be recovered.

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


Dependencies
============

* `Rust (edition 2018) `_ 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`:

.. code:: sh

cargo install disktest


Installing from source package
==============================

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

.. code:: sh

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


Running from source package without installing
==============================================

Build and run disktest in place without installing it:

.. code:: sh

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.

.. code:: sh

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

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 -j4 -ACHACHA20 -w /dev/null ChaCha20 Intel i5-3320M; 2+2 cores 2.6 GHz 2.0 GiB/s
disktest -j4 -ACHACHA12 -w /dev/null ChaCha12 Intel i5-3320M; 2+2 cores 2.6 GHz 3.1 GiB/s
disktest -j4 -ACHACHA8 -w /dev/null ChaCha8 Intel i5-3320M; 2+2 cores 2.6 GHz 4.2 GiB/s
disktest -j4 -ACRC -w /dev/null CRC Intel i5-3320M; 2+2 cores 2.6 GHz 4.6 GiB/s
disktest -j6 -ACHACHA20 -w /dev/null ChaCha20 AMD Phenom II X6 1090T; 6 cores 3.2 GHz 3.0 GiB/s
disktest -j6 -ACHACHA12 -w /dev/null ChaCha12 AMD Phenom II X6 1090T; 6 cores 3.2 GHz 3.9 GiB/s
disktest -j6 -ACHACHA8 -w /dev/null ChaCha8 AMD Phenom II X6 1090T; 6 cores 3.2 GHz 4.5 GiB/s
disktest -j6 -ACRC -w /dev/null CRC AMD Phenom II X6 1090T; 6 cores 3.2 GHz 6.3 GiB/s
disktest -j4 -ACHACHA20 -w /dev/null ChaCha20 Raspberry Pi 4; 4 cores 1.5 GHz 300 MiB/s
disktest -j4 -ACHACHA12 -w /dev/null ChaCha12 Raspberry Pi 4; 4 cores 1.5 GHz 400 MiB/s
disktest -j4 -ACHACHA8 -w /dev/null ChaCha8 Raspberry Pi 4; 4 cores 1.5 GHz 500 MiB/s
disktest -j4 -ACRC -w /dev/null CRC Raspberry Pi 4; 4 cores 1.5 GHz 680 MiB/s
==================================== ========= ======================================= =================

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

Note: The default rust compiler shipped with Raspberry Pi OS is too old to compile Disktest. A newer Rust compiler must be used on Raspberry Pi.


License
=======

Copyright (c) 2020 Michael Buesch

Licensed under the terms of the GNU General Public License version 2, or (at your option) any later version.