How to use the command systemd-repart (with examples)

How to use the command systemd-repart (with examples)

Systemd-repart is a command that automates the process of growing and adding partitions based on the configuration files described in repart.d. This command does not automatically resize the file system on the partition; for extending the file system, one should refer to systemd-growfs. Let’s explore a few use cases to understand how to utilize this command effectively.

Use case 1: Grow the root partition (/) to all available disk space

Code:

systemd-repart

Motivation: Growing the root partition to utilize all available disk space can be useful when the current partition is running out of space and needs to be expanded to accommodate more data. This can prevent issues such as applications crashing or the system becoming unresponsive due to insufficient disk space.

Explanation: Running the systemd-repart command without any arguments will automatically grow the root partition (/) to utilize all available disk space on the disk.

Example output:

Partition ROOT expanded successfully to utilize all available disk space.

Use case 2: View changes without applying

Code:

systemd-repart --dry-run=yes

Motivation: It is crucial to review the changes before applying them. This helps prevent any unintended consequences that may arise due to misconfiguration or incorrect partition resizing. By using the --dry-run=yes parameter, you can preview the changes without actually applying them.

Explanation: The --dry-run=yes argument instructs the systemd-repart command to simulate the changes and display the potential outcome without actually making any modifications to the partitions.

Example output:

Dry-run mode enabled. This is the preview of the partition changes that would take place:
- Partition ROOT will be expanded to utilize all available disk space.

Use case 3: Grow root partition size to 10 gigabytes

Code:

systemd-repart --size=10G --root /

Motivation: Sometimes it may be necessary to allocate a specific amount of disk space to a partition, irrespective of the available space. This can be useful when there are requirements or constraints related to the partition size, such as application-specific needs or in scenarios where specific disk sizes are desired for logical separation.

Explanation: The --size=10G argument specifies the desired size of the root partition in gigabytes. In this example, it will be set to 10 gigabytes. The --root / parameter specifies the target partition to resize.

Example output:

Partition ROOT resized successfully to 10 gigabytes.

Conclusion:

Systemd-repart offers a straightforward way to automate the process of growing and adding partitions based on the configuration files. By understanding the different use cases and how to utilize the command effectively, you can efficiently manage and resize partitions on your system.

Related Posts

Understanding and Managing btrfs Filesystems (with examples)

Understanding and Managing btrfs Filesystems (with examples)

Introduction The btrfs filesystem is a modern and feature-rich filesystem for Linux systems.

Read More
Changing the remote for pulling and pushing (with examples)

Changing the remote for pulling and pushing (with examples)

Use case 1: Change the upstream remote to origin git rename-remote upstream origin Motivation In this use case, we want to change the remote repository used for pulling and pushing to the new “origin” repository.

Read More
How to use the command 'pio lib' (with examples)

How to use the command 'pio lib' (with examples)

The ‘pio lib’ command is used to manage PlatformIO libraries. This command provides various functionalities to list, search, install, update, and uninstall libraries within a PlatformIO project.

Read More