fdisk and parted are command-line utilities in Linux for managing disk partitions. While both serve the same purpose, they come with different features and compatibilities.
fdisk
fdisk is a traditional disk partitioning tool primarily designed for MBR (Master Boot Record) partition tables.
Key Features
- MBR Support: Traditionally used for creating and manipulating MS-DOS partition tables.
- GPT Support: Recent versions support GPT (GUID Partition Table) but it's considered experimental.
- Interactive Mode: Offers a menu-driven interface.
- Automatic Alignment: Aligns partitions on a one-megabyte boundary when DOS compatibility mode is off.
- Scripting: Can be used in scripts, although not as straightforward.
Usage
# Launch fdisk in interactive mode
sudo fdisk /dev/sda
# Sample commands in interactive mode
n # Create a new partition
p # Print the partition table
w # Write changes
parted
parted is a more modern tool designed to handle large disks and supports multiple partition table formats.
Key Features
- GPT and MBR Support: Can manipulate both GPT and MBR partition tables.
- Larger Disk Support: Can handle disks larger than 2TB.
- More Partitions: Supports up to 128 partitions in GPT by default.
- Resizing: Can shrink and extend partitions.
- Interactive and Command-Line Modes: Offers flexibility in usage.
- Alignment: Warns about improper alignment but aligns only the partition start.
Usage
# Command-line mode
sudo parted /dev/sda print
# Interactive mode
sudo parted
(parted) print
# Create a partition
sudo parted /dev/sda mkpart primary ext4 0GB 1GB
fdisk vs parted - Difference
The notable difference is that parted support shrinking and extending for partitions. When comes to larger disks parted is preferred, considering fdisk GPT is in an experimental phase.
Comparison of fdisk and parted presented in a table format:
Feature | fdisk | parted |
---|---|---|
Partition Table Support | MBR (GPT supported but experimental) | MBR, GPT |
Disk Size Limit | Traditional limit of 2TB | Can handle disks larger than 2TB, potential to address up to 8 zebibytes of space. |
Partition Alignment | Automatic (if DOS compatibility is off) | Aligns only the start, warns on improper alignment |
Display of Disk Size | Uses binary (ex: GiB) | Display in decimal (ex: GB) (May round to nearest number) |
Resizing Partitions | No | Yes (Can shrink and extend) |
Usage Modes | Interactive mode | Interactive and Command-line modes |
Scripting Capability | Possible, though not straightforward | Suitable for scripting |
EFI Partition Creation | Yes (with GPT) | Yes |
Number of Partitions | Limited (up to 16 with MBR) | Up to 128 by default with GPT (can be more) |
Reliability Features | Single copy of partition table (MBR) | Two copies of partition table, CRC checksum (GPT) |
Availability | Usually pre-installed in most distributions | May need to be installed in some distributions |
Comments