#disk #ata #smart #libatasmart #attributes

libglacierdisk

A linux library for reading disk data and benchmarking

5 unstable releases

0.7.0 Mar 25, 2025
0.6.1 Feb 20, 2025
0.6.0 Feb 16, 2025
0.5.1 Feb 15, 2025
0.5.0 Feb 15, 2025

#375 in Hardware support

Download history 311/week @ 2025-02-13 130/week @ 2025-02-20 7/week @ 2025-02-27 2/week @ 2025-03-06 84/week @ 2025-03-20 33/week @ 2025-03-27 1/week @ 2025-04-10

118 downloads per month

MIT license

29KB
764 lines

libglacierdisk

This is the underlying library that powers the GlacierDiskInfo project. It is a linux-only library for interfacing with and reading SMART (and other) data from disks.

Usage

Run the following:

cargo add libglacierdisk

Examples

List and log disks

 use libglacierdisk;

 let disks = libglacierdisk::list_disks()?;
 for disk in disks {
   println!("{:?}", disk);
 }

Get a specific disk

use libglacierdisk::{ disk::Disk };

let disk = Disk::new("/dev/sda").unwrap();
println!("{:?}", disk);

Get the temperature of a disk

use libglacierdisk;

let disks = libglacierdisk::list_disks()?;
let first = disks.first()?;

// This will be in mkelvin
println!("{:?}", disk.raw_disk().get_temperature());

Get a specific SMART attribute

use libglacierdisk;

let disks = libglacierdisk::list_disks()?;
let first = disks.first()?;

let attribute = first.get_attribute("total-lbas-read")?;
println!("{:?}", attribute);

Perform a random-write benchmark

use libglacierdisk::{
  benchmark::{Benchmark, BenchmarkConfig, BenchmarkType, GlacierDiskBenchmark},
};

let disks = libglacierdisk::list_disks()?;
let first = disks.first()?;

let mut benchmark = GlacierDiskBenchmark::new(
  // Disk
  first.clone(),
  // First mount
  0,
  BenchmarkConfig {
    random: true,
    kind: BenchmarkType::Write,
    ..BenchmarkConfig::default()
  },
)
.unwrap();

let result = benchmark.run().unwrap();

println!("Total time: {:.2}s", result.elapsed.as_secs_f32());
println!("Average speed: {:.2}MB/s", speed_to_mb(result.avg_speed));

Dependencies

~3.5MB
~82K SLoC