gptman
A CLI tool for Linux that allows you to copy a partition from one disk to another and more.
A library that allows managing GUID partition tables.
Features
- Read/Write GPT from 512 and 4096 bytes sector size disks
- Create a new GPT on a disk (-i, --init)
- Insert/delete a partition in the table (n, d)
- Align partitions automatically (a)
- Resize a partition (r)
- Copy/clone a partition from one disk and insert it to another (c)
- Change partition type (and list by category) (t)
- Fix partitions order (f)
- Change disk GUID (i)
- Change partition name (L)
- Change partition GUID (u)
- Toggle legacy BIOS bootable (A)
- Toggle no block IO protocol (B)
- Toggle required partition flag (R)
- Toggle attributes (S)
- Customize columns to print (-o, --output)
- Print raw data of disklabel (D)
- Swap partition indexes (s)
- Randomize disk's GUID and all partition's GUID (Z)
- Copy/clone all partitions from one disk and insert it to another (C)
Installation
-
CLI:
cargo install gptman
Statically linked:
cargo install --target=x86_64-unknown-linux-musl gptman
-
Library:
Cargo.toml:
[] = { = "0.2.0", = false }
Library Usage
Reading all the partitions of a disk:
let mut f = open
.expect;
let gpt = GPT find_from
.expect;
println!;
for in gpt.iter
Creating new partitions:
let mut f = open
.expect;
let mut gpt = GPT find_from
.expect;
let free_partition_number = gpt.iter.find.map
.expect;
let size = gpt.get_maximum_partition_size
.expect;
let starting_lba = gpt.find_optimal_place
.expect;
let ending_lba = starting_lba + size - 1;
gpt = GPTPartitionEntry ;
Creating a new partition table with one entry that fills the entire disk:
let ss = 512;
let data = vec!;
let mut cur = new;
let mut gpt = GPT new_from
.expect;
gpt = GPTPartitionEntry ;