What is the usage of the parted command?
parted is a command line tool used in Linux for partitioning disks, allowing users to create, delete, resize partitions, and view partition tables.
Basic usage of the parted command is as follows:
- Open the parted tool by entering “parted” in the command line followed by the path of the disk device (for example, /dev/sda).
- To view the disk partition table: In the parted interface, entering the print command allows you to view information about the disk’s partition table.
- To create a partition: you can use the mkpart command to create a new partition. The command syntax is mkpart [file system type] [start position] [end position], for example, mkpart primary ext4 0% 50% indicates creating a primary ext4 partition starting at 0% of the disk and ending at 50%.
- Delete partition: You can use the rm command to delete a specific partition. The command syntax is rm [partition number], for example, rm 1 means to delete the first partition.
- Adjusting partition size: The size of a partition can be adjusted using the resizepart command. The command syntax is resizepart [partition number] [new size], for example resizepart 2 20GB means to adjust the size of the second partition to 20GB.
- Formatting partitions: The mkfs command can be used to format a specified partition. The command syntax is mkfs [file system type] [partition path], for example mkfs ext4 /dev/sda1 indicates formatting /dev/sda1 partition with ext4.
- Exit the parted tool: To leave the parted interface, simply type the quit command.
Please be aware that the parted command requires root permissions for partition operations. Proceed with caution when using this command and make sure to back up important data before any operations.