Home > Package & System Management > systemd-repart

systemd-repart: Automatic Disk Partition Expansion and Creation

systemd-repart is a utility used to automatically expand or create disk partitions. It is primarily utilized during the system's first boot or during system updates to dynamically adjust the partition layout. It operates based on JSON-formatted partition definition files and supports a dry-run mode for safe modifications.

Overview

systemd-repart reduces the hassle of manual partition adjustments for system administrators, enabling flexible disk management, especially in cloud or embedded environments.

Key Features

  • Automatic Partition Expansion: Expands existing partitions to utilize available space.
  • New Partition Creation: Creates new partitions based on defined rules.
  • JSON-based Configuration: Defines partition layouts via JSON files located in /etc/repart.d/ or /usr/lib/repart.d/.
  • Safe Simulation: Allows previewing results without actual changes using the --dry-run option.

Key Options

systemd-repart provides various options to control the details of partition operations.

Execution Control

Generated command:

Try combining the commands.

Description:

`systemd-repart` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

systemd-repart is typically invoked by system boot scripts or management tools, but it can be run manually to simulate or apply partition changes.

Simulate Partition Changes (Most Important)

sudo systemd-repart --dry-run

Check in advance what operations systemd-repart will perform without making actual changes. This option must be used before applying changes.

View Simulation Results in JSON Format

sudo systemd-repart --dry-run --json=pretty

Output simulation results in JSON format for programmatic analysis.

Simulate Partition Changes with Specific Definition Files

sudo systemd-repart --dry-run --definitions=/path/to/custom/repart.d

Simulate using partition definition files located in a specific directory, not the default path.

Apply Actual Partition Changes (Use with Caution)

sudo systemd-repart

After thoroughly reviewing with dry-run, apply actual partition changes. This operation carries a risk of data loss, so it must be performed cautiously after backing up.

Tips & Precautions

When using systemd-repart, prioritize data safety and system stability.

Key Usage

  • Always use --dry-run first: Before applying any actual changes, always use the `--dry-run` option to verify the expected modifications.
  • Data backup is essential: Partition changes carry a risk of data loss, so always back up important data.
  • repart.d definition files: systemd-repart reads JSON-formatted partition definition files from `/usr/lib/repart.d/` and `/etc/repart.d/` to perform its operations. Understanding and modifying these files is crucial.
  • Usage during system boot: This command is primarily used automatically during the system's first boot or OS update process to adjust partition layouts. Manual execution is recommended only for specific purposes.


Same category commands