Tool to validate the actual size of drive (against the drive's declared size).
This tool is:
- An implementation of the concepts from Steve Gibson's ValiDrive.
- Command-line based
- Implemented for Linux (although support can be added for other OSes).
The motivations for creating this tool were:
- The original ValiDrive is a Windows-only tool.
- It seemed like a good project for me to learn Rust.
This tool will:
- Subdivide the drive in 576 (configurable) areas, and select a 4 KiB (configurable) block for testing at the end of each area.
- Read the content of those blocks and save it (so that it can be restored at the end of the test).
- Overwrite those blocks in a random order with random data.
- Read back the blocks and compare the content with what was written.
- If the content matches, mark the block as "Validated". If the content does not match, mark the block as "No storage".
- Print a map of the validation of each block, along with the validated drive size (i.e. the highest validate block not preceded by not validated blocks).
- Write back the original block content.
- Ensure you have the Rust compiler installed.
- Build valixdrive with
cargo build -r
. - Execute
./target/release/valixdrive
.
Usage: valixdrive [OPTIONS] --drive <DRIVE>
Options:
-d, --drive <DRIVE> The storage device to test
-b, --block-size-kb <BLOCK_SIZE_KB> The block size to read/write in KiB [default: 4]
-n, --num-blocks <NUM_BLOCKS> The number of blocks to test [default: 576]
-R, --read-only Perform only a read test
-w, --map-width <MAP_WIDTH> Width in columns of the validation map printed on the terminal [default: 64]
-O, --no-restore-original Do not read and restore original blocks values
-h, --help Print help
-V, --version Print version
- This tools access the drive with O_DIRECT and O_SYNC, which is supposed to bypass and OS cache
and ensure data is read/written directly from/to the drive. However the device may have some
write cache in the drive. If the drive cache is more than the data written to the device
(
num-blocks * block-size
, which defaults to 2.25 MiB), the drive may fool this tool. If a large hardware cache is suspected, the number of blocks written and/or the block size should be increased. - If you get the error
Device or resource busy (os error 16)
, it is likely your OS auto-mounted a partition from the USB drive and you need to unmount it, before you can use this tool.
- Add unit test coverage.
- Setup a Github test & build pipeline.
- Save the original block content to persistent storage, so that it can be used to recover the content of the drive in case of interruption or crash.
- In alternative to writing the original block content back, support for writing zeros or issuing TRIM/DISCARD commands for the whole device.
- Automatically un-mount partitions before opening the drive.
- Detect hardware drive write cache presence and size.
MIT License
Copyright (c) 2024 Ludovico Cavedon ludovico.cavedon@gmail.com
See LICENSE.