The parted command in Linux is a command-line utility for working with partitions on a hard disk. It allows you to create, modify, delete, and move partitions on a disk.
Some common uses of the parted command include:
parted /dev/sda mkpart primary 0% 100%. This command creates a new primary partition on the /dev/sda disk, occupying all available space.Resize partition: parted /dev/sda resizepart 1 10GB. This command resizes the first partition on the /dev/sda disk to 10 gigabytes.parted /dev/sda rm 1. Deletes the first partition on the /dev/sda disk.parted /dev/sda move 1 50%. Moves the first partition on the /dev/sda disk so that it occupies the first half of the available space.parted also provides other functions such as displaying partition information, formatting partitions, etc. For more information about the parted command, you can use the man parted command in the Linux terminal.
The syntax of parted command is as follows:
parted [options] [device]
Options:
-a, --align=type
Set the partition alignment type
-s, --script
Run in script mode without interactive input
-m, --machine
Output machine-readable output format
-l, --list
Output a list of partitions on the device
-v, --version
Output parted version information
-h, --help
Print help on how to use the command
Device: Specifies the path to the device that the parted command will work with. For example, /dev/sda.
Examples of using the parted command
1. parted /dev/sda mkpart primary 0% 100%
2. parted /dev/sda resizepart 1 10GB
3. parted /dev/sda rm 1
4. parted /dev/sda move 1 50%
Note that the parted command requires root privileges.