Methods of payment Abuse

The parted command in Linux

04.10.2023, 23:29

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 the disk.

Usage examples

Some common uses of the parted command include:

  1. Creating a new partition: parted /dev/sda mkpart primary 0% 100%. This command creates a new main partition on the /dev/sda disk, occupying all the available space.
  2. Changing the partition size: parted /dev/sda resizepart 1 10GB. The command changes the size of the first partition on the /dev/sda disk to 10 gigabytes.
  3. Deleting a partition: parted /dev/sda rm 1. Deletes the first partition on the disk /dev/sda.
  4. Moving the partition: 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.

Parted syntax

The syntax of the parted command looks like this:

parted [options] [device]

Options:

-a, --align=type

Set the alignment type of the section

-s, --script


Run in script mode without interactive input

-m, --machine

Output machine-readable output format

-l, --list

Display a list of partitions on the device

-v, --version

Output information about the parted version

-h, --help

Output help on using 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 superuser (root) rights are required to execute the parted command.