summaryrefslogtreecommitdiffstats
path: root/README.rst
blob: 65371c176d40787a4dae29ff779e573fa5d97a40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
disktest - Hard Disk (HDD), Solid State Disk (SSD), USB Stick, Memory Card (e.g. SD-Card) tester
================================================================================================

`https://bues.ch/h/disktest <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 a concatenation of hashes generated by the following algorithm:
::

	S := PBKDF2(SEED | THREAD_ID)
	LOOP {
		HASH_DATA[I] := SHA512(S | HASH_DATA[I-1] | I)
		I := I + 1
	}

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

The algorithm can also be switched to a CRC based algorithm, that is much faster, but *not* cryptographically secure. However CRC is sufficient to find physical disk errors. Disktest defaults to the secure SHA512 based algorithm.


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

* `Rust (edition 2018) <https://www.rust-lang.org/>`_ or later.
* Crate dependencies will automatically be downloaded by cargo.


Installing from crates.io
=========================

Download the latest version of disktest from `crates.io <https://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 -j6 -w /dev/null        SHA512     AMD Phenom II X6 1090T; 6 cores 3.2 GHz  675 MiB/s
disktest -j6 -ACRC -w /dev/null  CRC        AMD Phenom II X6 1090T; 6 cores 3.2 GHz  4.6 GiB/s
disktest -j4 -w /dev/null        SHA512     Intel i5-3320M; 2+2 cores 2.6 GHz        250 MiB/s
disktest -j4 -ACRC -w /dev/null  CRC        Intel i5-3320M; 2+2 cores 2.6 GHz        3.4 GiB/s
disktest -j4 -w /dev/null        SHA512     Raspberry Pi 4; 4 cores 1.5 GHz          75 MiB/s
disktest -j4 -ACRC -w /dev/null  CRC        Raspberry Pi 4; 4 cores 1.5 GHz          605 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 <m@bues.ch>

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