Lesson 48: parted Command
In this lesson, you'll learn how to use the parted command to create, delete, resize, and manage disk partitions in Linux.
parted is a renowned command-line utility designed to facilitate the management of hard disk partitions in a user-friendly manner.
With parted, you can effortlessly perform tasks such as adding, deleting, shrinking, and extending disk partitions, while also managing the file systems associated with them.
Over time, parted has undergone significant development and evolution, introducing various enhancements and changes to its functionality.
Certain features have been retired, while new capabilities have been introduced, rendering it a versatile tool for partition management.
Note: If you are new to parted, it is essential to note that any modifications made using parted are immediately written to the disk.
If you intend to experiment with parted, it is recommended to utilize a virtual machine or an old computer/laptop that does not contain any critical data.
When making modifications to a disk partition, it is crucial that the partition is not actively in use.
In the case of primary partitions, you may consider booting into rescue mode, which provides a safe environment for performing partition-related tasks without interference from the running operating system.
This precautionary approach ensures the integrity of your valuable data and minimizes the risk of unintended consequences during partition manipulation.
Note: You will need to have root access to the machine you will be working on in order to use parted.
Install parted on Linux
On many Linux distributions, parted comes pre-installed. If it is not included in your distro, you can install it with:
$ sudo apt install parted # Debian, Ubuntu and Mint
$ sudo yum install parted # RHEL/CentOS/Fedora and Rocky/AlmaLinux
$ sudo emerge -a sys-apps/parted # Gentoo Linux
$ sudo apk add parted # Alpine Linux
$ sudo pacman -S parted # Arch Linux
$ sudo zypper install parted # OpenSUSE
Once you have made sure that parted is installed, you can proceed further to check out some real-world examples of the parted command in the rest of this article.