#image #clone #flash #cli #os #cli-tool

bin+lib liblitho

用于将图像克隆/刷入存储设备的命令行工具

1 个不稳定版本

0.1.0 2024年6月2日

#17#flash

Download history 74/week @ 2024-05-27 94/week @ 2024-06-03 7/week @ 2024-06-10

每月175次下载

MIT 许可证

24KB
539

Litho

一个简单轻量级的库和 CLI 工具,用于将图像写入块设备。

命令用法

  • 将设备克隆到镜像文件
litho clone --help
Usage: litho clone [OPTIONS] --file <FILE> --device <DEVICE>

Options:
  -f, --file <FILE>              file to which device should be cloned
  -d, --device <DEVICE>          device
  -b, --block-size <BLOCK_SIZE>  block size
  -s, --silent <SILENT>          message to be published [possible values: true, false]
  -h, --help                     Print help
  • 将镜像文件刷入设备
litho flash --help
Usage: litho flash [OPTIONS] --file <FILE> --device <DEVICE>

Options:
  -f, --file <FILE>              file to be written to the device
  -d, --device <DEVICE>          device
  -b, --block-size <BLOCK_SIZE>  block size
  -s, --silent <SILENT>          message to be published [possible values: true, false]
  -h, --help                     Print help

API 使用

  • 将设备克隆到镜像文件
use litho::clone;
let image = "/home/user/image-file.img".to_string();
let device = "/dev/sda".to_string();
let block_size = 4096;

fn callback_fn(percentage: f64) {
    println!("{percentage}%");
}

litho::clone(image, device, block_size as usize, false, callback);
  • 将镜像文件刷入设备
use litho::flash
let image = "/home/user/image-file.img".to_string();
let device = "/dev/sda".to_string();
let block_size = 4096;

fn callback_fn(percentage: f64) {
    println!("{percentage}%");
}

litho::flash(image, device, block_size as usize, false, callback);

依赖项

~5–17MB
~221K SLoC