Overview
Disk partitioning divides a physical disk into separate logical sections. fdisk is the traditional MBR partition editor, while parted supports both MBR and GPT (required for disks larger than 2 TB). Understanding both tools is essential for managing storage on your Breeze or dedicated server.
Listing Existing Partitions
# Using fdisk
sudo fdisk -l
# Using parted
sudo parted -l
# Using lsblk (quick visual overview)
lsblk
# Detailed block device info
lsblk -f
Working with fdisk (MBR)
# Open fdisk for a specific disk
sudo fdisk /dev/sdb
Interactive commands within fdisk:
p— Print current partition tablen— Create a new partitiond— Delete a partitiont— Change partition typew— Write changes and exitq— Quit without saving
Creating a Partition with fdisk
sudo fdisk /dev/sdb
# Type: n (new partition)
# Select: p (primary) or e (extended)
# Partition number: 1
# First sector: press Enter for default
# Last sector: +50G (for a 50GB partition) or Enter for full disk
# Type: w (write and exit)
Working with parted (GPT)
# Open parted for a disk
sudo parted /dev/sdb
# Create a GPT partition table
(parted) mklabel gpt
# Create a partition using the full disk
(parted) mkpart primary ext4 0% 100%
# Create a 50GB partition starting at the beginning
(parted) mkpart primary ext4 1MiB 50GiB
# Print partition table
(parted) print
# Remove a partition
(parted) rm 1
# Exit
(parted) quit
Non-Interactive parted
# Create GPT label and single partition in one command
sudo parted /dev/sdb --script mklabel gpt
sudo parted /dev/sdb --script mkpart primary ext4 0% 100%
After Partitioning
# Inform the kernel of partition changes
sudo partprobe /dev/sdb
# Format the new partition
sudo mkfs.ext4 /dev/sdb1
# Or for XFS
sudo mkfs.xfs /dev/sdb1
# Create mount point and mount
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
# Verify
df -h /mnt/data
# Add to fstab for persistent mounting
# Get the UUID first
sudo blkid /dev/sdb1
# Add entry
echo "UUID=your-uuid-here /mnt/data ext4 defaults 0 2" | sudo tee -a /etc/fstab
Resizing Partitions
# Resize with parted (grow a partition)
sudo parted /dev/sdb
(parted) resizepart 1 100%
(parted) quit
# Then resize the filesystem
sudo resize2fs /dev/sdb1 # For ext4
sudo xfs_growfs /mnt/data # For XFS
MBR vs GPT
- MBR — Legacy, supports up to 2 TB disks, maximum 4 primary partitions
- GPT — Modern, supports disks larger than 2 TB, up to 128 partitions, includes backup partition table
- Use GPT for any new disk setup unless you have a specific MBR requirement