How to create a new partition using the parted command?

To create a new partition using the parted command, follow these steps:

  1. Open the terminal.
  2. Use the following command to launch the parted command line interface:
  3. Give permission to parted
  4. Note: You need to run the parted command with administrative privileges.
  5. Select the disk that you want to partition. For example, if you want to partition /dev/sda, you can enter the following command:
  6. Choose /dev/sda
  7. Use the command “print” to view the partition status of the disk, which will display a list of existing partitions on the disk.
  8. To create a new partition table, use the mklabel command. For example, if you want to create a new GPT partition table, you can input the following command:
  9. Create a GPT label.
  10. Alternatively, you can choose MBR partition table by entering the following command:
  11. Set the label to msdos.
  12. To create a new partition, use the command mkpart. This command requires specifying the type of partition (primary, extended, or logical), the starting position, and the ending position. For example, to create a primary partition, you can input the following command:
  13. Create a primary partition with the specified file system type, starting position, and ending position.
  14. The can be ext4, ntfs, fat32, etc. The and can be represented using MBR or GBR, for example, 10GB.
  15. To create a logical partition, you can enter the following command:
  16. create a logical partition with starting at and ending at
  17. Use the “print” command to view the newly created partition.
  18. To exit the parted command line interface, use the quit command.

Before using the parted command to create a new partition, make sure to back up all important data on the disk to prevent any unexpected data loss.

bannerAds