parted
is a more advanced tool than fdisk
, suitable for both MBR and GPT partitioning.
Steps:
- Open
parted
with the target disk:
sudo parted /dev/sdX
Sample Output:
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
- Set the Disk Label (only if you want to create a new label like GPT or MBR):
(parted) mklabel gpt
Sample Output:
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
- Create a New Partition:
(parted) mkpart primary ext4 1MiB 5GiB
primary
is the partition type.ext4
is the file system type (optional).1MiB
is the start point, and5GiB
is the end point of the partition.
Sample Output:
(parted) mkpart primary ext4 1MiB 5GiB
- Quit Parted:
(parted) quit
Sample Output:
Information: You may need to update /etc/fstab.
- Format the New Partition:
sudo mkfs.ext4 /dev/sdX1
Sample Output:
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: a8c9c2d4-8e9c-432b-8ae4-d6e94cbd1e59
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
- Mount the Partition:
sudo mkdir /mnt/new_partition
sudo mount /dev/sdX1 /mnt/new_partition
Sample Output:
(no output if successful)