systemd-repart
Repartition a disk without rebooting
TLDR
Grow the root partition (/) to all available disk space
View changes without applying
Grow root partition size to 10 gigabytes
SYNOPSIS
systemd-repart [OPTIONS...] [DEVICE]
PARAMETERS
-h, --help
Show help message and exit.
--version
Show package version and exit.
--root=PATH
Operate on the specified root directory PATH instead of the host's root directory.
--dry-run
Perform a trial run with no actual changes made. Useful for testing disk layout changes safely.
--image=FILE
Operate on a disk image FILE instead of a physical device. The image file will be mounted loopback if needed.
--list
List the configured partition types and their GUIDs that systemd-repart knows about.
--grow
Automatically grow the last suitable partition (typically the root filesystem) to fill the remaining available space on the disk.
--erase
Erase the existing partition table on the DEVICE before applying the new layout. Caution: Data loss will occur.
--force
Force the operation, overriding certain safety checks or existing conditions.
--json=MODE
Output log data in JSON format. Supported modes include 'short', 'pretty', 'off'.
DEVICE
The disk device to operate on, e.g., /dev/sda or /dev/nvme0n1.
DESCRIPTION
systemd-repart is a powerful utility designed for managing disk partitions, primarily within a systemd-centric environment. It enables declarative partitioning, allowing systems to automatically reconfigure and resize partitions based on predefined layouts or existing images. This tool is especially useful for initial system setup, system updates, and preparing disk images for deployment. It can create and grow partitions, erase existing tables, and work with disk images or physical devices. While it can be destructive if not used carefully, its --dry-run option allows for safe testing. It integrates well with other systemd tools, offering a streamlined approach to disk provisioning and maintenance, supporting modern GPT partition tables and specific partition types like EFI System Partitions, root filesystems (A/B), and swap.
CAVEATS
Using systemd-repart without the --dry-run option can be highly destructive and lead to irreversible data loss, especially when using the --erase or --force options. It primarily works with GPT (GUID Partition Table) and expects specific partition type GUIDs. It is not an interactive partitioning tool like fdisk or parted, but rather a declarative one designed for automated system provisioning and updates within the systemd ecosystem.
USE CASES
systemd-repart is commonly used for:
1. Initial OS Installation: Applying a predefined disk layout from a system image onto a blank disk.
2. A/B Root Filesystems: Managing and switching between dual root partitions for robust system updates.
3. Automated Resizing: Automatically expanding the root filesystem on first boot to utilize full disk capacity.
4. Embedded Systems: Ensuring consistent and reproducible disk layouts across many devices.
PARTITION TYPE GUIDS
Unlike traditional tools that rely on partition numbers, systemd-repart often identifies partitions by their specific GPT Partition Type GUIDs (e.g., c12a7328-f81f-11d2-ba4b-00a0c93ec93b for EFI System Partition, 4f68bce3-e8cd-4db1-96e7-fbcaf98b0f79 for Linux root A, 69dad710-2ce4-4e3c-b16c-21a1d49abed3 for Linux swap). This allows for a more robust and flexible approach to managing partitions across different systems or update scenarios.
HISTORY
Part of the broader systemd project, systemd-repart was developed to address the need for automated, reproducible, and declarative disk partitioning, particularly for modern Linux installations and embedded systems. It aligns with systemd's philosophy of providing integrated solutions for system management, simplifying tasks like initial system setup, A/B updates, and disk image deployment by leveraging predefined partition layouts and GUIDs.
SEE ALSO
systemd-firstboot(1), systemd-sysext(1), parted(8), fdisk(8), mkfs(8), mount(8), sfdisk(8)