Stop Partitioning Disks by Hand: Practical systemd-repart on Linux
Every hand-built Linux image eventually grows the same wart: a shell script that pipes commands into sfdisk , calls partprobe , runs resize2fs , and hopes the device really was /dev/sda . It works exactly once. Change the disk, add a partition, or boot the same image on a board that enumerates storage differently, and the script either fails halfway or, worse, succeeds against the wrong device.…
Systemd-repart is a tool that helps in managing disk partitions declaratively. It uses .conf files to define the desired partitions and their properties, such as type, size, and filesystem. The tool reads these files, matches them against existing partitions, and adjusts the partition table accordingly. It is designed to be incremental, leaving existing partitions unchanged unless a matching definition is found.
The tool is GPT only and does not support MBR/DOS partition tables, shrinking, moving, or deleting partitions. It does not perform filesystem growth or content migration. The partition allocation is based on SizeMinBytes, SizeMaxBytes, and Weight settings, with defaults that can lead to unexpected results, such as a root partition taking up the entire disk. The tool provides a dry-run mode to preview changes before making them.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.