rsfdisk
⚠️ WARNING: This library is still in development, thus not yet suitable for use in production.
The rsfdisk library is a safe Rust wrapper around util-linux/libfdisk.
rsfdisk can create and/or manipulate partition tables on block devices. It
understands GPT, MBR, Sun, SGI, and BSD partition tables.
Usage
This crate requires libfdisk version 2.39.2 or later.
Add the following to your Cargo.toml:
[]
= "0.2.0"
Then install the system packages below before running cargo build:
util-linux: to generate Rust bindings fromlibfdisk's header files.libclang: to satisfy the dependency ofbindgenonlibclang.pkg-config: to detect system libraries.
Read the installation instructions below to install the required dependencies on your system.
Example
In this example we create a GPT partition table on /dev/vda, then divide it
into three partitions:
- a 16 GiB
rootpartition to keep system files, - and two 64 GiB data partitions.
use Fdisk;
use PartitionTableKind;
use Guid;
use Partition;
use PartitionKind;
use PartitionList;
Install required dependencies
Alpine Linux
As root, issue the following command:
apk add util-linux-dev clang-libclang pkgconfig
NixOS
Install the packages in a temporary environment with:
nix-shell -p util-linux.dev libclang.lib pkg-config
or permanently with:
nix-env -iA nixos.util-linux.dev nixos.libclang.lib nixos.pkg-config
Ubuntu
sudo apt-get install libfdisk-dev libclang-dev pkg-config
License
This project is licensed under either of the following:
at your discretion.
Files in the third-party/ and web-snapshots/ directories are subject to their own licenses and/or copyrights.
SPDX-License-Identifier: Apache-2.0 OR MIT
Copyright (c) 2023 Nick Piaddo