The GNU parted utility is also used to view the existing partition table, change the size of existing partitions, or add partitions from free space or additional hard drives. This utility is more advanced than the fdisk utility. It supports more disk label types and offers additional commands. parted syntax is:
# parted [option] [device_name] [command [argument]]
Use parted interactively to enter commands one at a time. Include only the device as an argument to invoke interactive mode. Example:
# parted /dev/sda GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)
From the (parted) prompt, enter a command or type help to view the list of available commands. Get additional help on a specific command by typing help plus the command. Example:
parted Command Examples
1. List partitions on all block devices:
# sudo parted --list
2. Start interactive mode with the specified disk selected:
# sudo parted /dev/sdX
3. Create a new partition table of the specified label-type:
# sudo parted --script /dev/sdX mklabel aix|amiga|bsd|dvh|gpt|loop|mac|msdos|pc98|sun
4. Show partition information in interactive mode:
5. Select a disk in interactive mode:
# select /dev/sdX
6. Create a 16 GB partition with the specified filesystem in interactive mode:
# mkpart primary|logical|extended btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|linux-swap|ntfs|reiserfs|udf|xfs 0% 16G
7. Resize a partition in interactive mode:
# resizepart /dev/sdXN end_position_of_partition
8. Remove a partition in interactive mode:
# rm /dev/sdXN