gptman
Pure Rust library to read and modify GUID partition tables.
Things you can do
- Read/Write GPT from 512 and 4096 bytes sector size disks
- Create a new GPT on a disk
- Insert/delete a partition in the table
- Align partitions automatically (to sector size)
- Resize a partition
- Copy/clone a partition from one disk and insert it into another
- Change partition type
- Fix partitions order
- Change disk GUID
- Change partition name
- Change partition GUID
- Toggle legacy BIOS bootable
- Toggle no block IO protocol
- Toggle required partition flag
- Toggle attributes
- Swap partition indexes
- Copy/clone all partitions from one disk and insert it to another
- Write protective MBR
Installation
Cargo.toml:
[]
= "1"
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 ;