How to create a new partition using the parted command?
To create a new partition using the parted command, follow these steps:
- Open the terminal.
- Use the following command to launch the parted command line interface:
- Give permission to parted
- Note: You need to run the parted command with administrative privileges.
- Select the disk that you want to partition. For example, if you want to partition /dev/sda, you can enter the following command:
- Choose /dev/sda
- Use the command “print” to view the partition status of the disk, which will display a list of existing partitions on the disk.
- 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:
- Create a GPT label.
- Alternatively, you can choose MBR partition table by entering the following command:
- Set the label to msdos.
- 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:
- Create a primary partition with the specified file system type, starting position, and ending position.
- The
can be ext4, ntfs, fat32, etc. The and can be represented using MBR or GBR, for example, 10GB. - To create a logical partition, you can enter the following command:
- create a logical partition with
starting at and ending at - Use the “print” command to view the newly created partition.
- 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.