A high-performance, cross-platform Rust library to list all connected storage devices. Inspired by Balena's drivelist, this crate provides a native Rust implementation to identify physical drives, their mount points, and metadata without the overhead of a heavy runtime.
Cross-Platform: Robust support for Linux and Windows. Detailed Metadata: Retrieve drive names, sizes, mount points, and whether a drive is removable or system-owned. Native Performance: Written in pure Rust for safety and speed. No External Dependencies: Minimalist approach to keep your binary small.
Add this to your Cargo.toml:
[dependencies]
rs-drivelist = "0.1.0" # Replace with latest versionuse rs_drivelist::list;
fn main() {
match list() {
Ok(drives) => {
for drive in drives {
println!("Device: {}", drive.device);
println!("Description: {}", drive.description);
println!("Size: {} bytes", drive.size);
println!("Mountpoints: {:?}", drive.mountpoints);
println!("-------------------");
}
}
Err(e) => eprintln!("Error retrieving drives: {}", e),
}
}| OS | Method | Status |
|---|---|---|
| Linux | util-linux / /sys/block |
✅ Supported |
| Windows | Logical & Physical Drive APIs | ✅ Supported |
| macOS | Objective C call | ☢️ In Progress |
Contributions are welcome! If you find a bug or want to add support for a new platform (like macOS), please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
My main laptop I used to start this project is broken, and I'm using a Celeron N2840 with unupgradable soldered 2GB RAM. Your donation will be very much appreciated, as my bank account couldn't bought me a proper machine. Visit me on my Ko-fi account