Understanding the Output:
- Disk /dev/sda: The physical disk device identifier. /dev/sda is typically the first SATA/SCSI disk
- Size information: Shows total disk capacity in both bytes and sectors
- Sector size: Usually 512 bytes (traditional) or 4096 bytes (Advanced Format)
- Disk label type: Either 'dos' (MBR) or 'gpt' (GUID Partition Table)
- Partitions: Each partition shows start/end sectors, size, and type
- EFI System: Boot partition for UEFI systems (typically 512MB)
- Linux filesystem: Main data partition, usually ext4, xfs, or btrfs
- Linux swap: Virtual memory swap space
Key Interactive Commands:
- m: Display the help menu (your best friend in interactive mode)
- p: Print current partition table (safe, read-only)
- n: Create a new partition
- d: Delete a partition
- t: Change partition type (filesystem identifier)
- w: Write changes to disk and exit (DANGER: This commits changes!)
- q: Quit without saving (safe exit)
- g: Create new GPT partition table (modern, recommended for disks > 2TB)
- o: Create new DOS/MBR partition table (legacy, limited to 2TB)
Interpreting Partition Information:
- Device: The partition device node (e.g., /dev/sda1)
- Start/End: Sector numbers where partition begins and ends
- Sectors: Total number of sectors in the partition
- Size: Human-readable partition size
- Type: Partition type identifier (EFI, Linux, swap, etc.)
- Disk model: Physical disk manufacturer and model information
- Disklabel type: GPT (modern) or DOS/MBR (legacy)
Step-by-Step Breakdown:
- n command: Initiates new partition creation
- Partition type: Primary (p) vs Extended (e). Primary partitions are bootable and limited to 4 on MBR disks
- Partition number: Choose 1-4 for primary partitions
- First sector: Pressing Enter accepts default (optimal alignment)
- Last sector: Use +size notation (+100G, +50M, +2T) for human-readable sizes
- Partition ID 83: Standard Linux filesystem identifier
- w command: Writes changes to disk (point of no return!)
- ioctl() call: Kernel notification to re-read partition table
Important Considerations:
- Unmount first: Always unmount the partition before deletion: sudo umount /dev/sdb2
- Data recovery: Deleted partition data may be recoverable until overwritten
- Partition numbering: After deletion, partition numbers don't automatically renumber
- Free space: Deleted partition becomes free space available for new partitions
- Boot issues: Deleting wrong partition can make system unbootable
- fstab entries: Remove or comment out /etc/fstab entries for deleted partitions
- LVM/RAID: Check if partition is part of LVM volume group or RAID array first
Common Partition Type Codes:
- 82: Linux swap / Solaris - Virtual memory swap partition
- 83: Linux - Standard Linux filesystem (ext2/3/4, xfs, btrfs, etc.)
- 8e: Linux LVM - Physical volume for Logical Volume Manager
- fd: Linux raid autodetect - Software RAID partition
- ef: EFI System - Boot partition for UEFI systems
- 07: HPFS/NTFS/exFAT - Windows filesystems
- 0b/0c: W95 FAT32 - Windows FAT32 filesystem
- a5: FreeBSD - FreeBSD partition
GPT vs MBR/DOS:
- Disk size limit: MBR max 2TB, GPT supports up to 9.4ZB (zettabytes)
- Partition count: MBR limited to 4 primary (or 3 primary + extended), GPT supports 128 partitions
- Data protection: GPT stores multiple copies of partition data for redundancy
- CRC checksums: GPT uses checksums to detect corruption
- UEFI requirement: Modern UEFI systems require GPT for boot drives
- Unique GUIDs: Each partition has globally unique identifier
- Partition names: GPT allows human-readable partition names (36 characters)
- Backwards compatibility: GPT includes protective MBR to prevent old tools from damaging disk
Understanding Free Space:
- Fragmented space: Multiple non-contiguous free space regions shown separately
- Sector ranges: Start and End sectors define exact location of free space
- Gap after sdb1: Space between partition 1 and 3 (209717248-419432447)
- End of disk: Space after last partition to end of disk
- Alignment considerations: Some space may be reserved for proper sector alignment
- Total calculation: Sum all free space regions for total available space
- Planning partitions: Use this info to determine optimal partition sizes
- Defragmentation: Consider reorganizing partitions to consolidate free space if needed
Key Information Fields:
- Device: Full partition device path
- Start/End: Exact sector boundaries of partition
- Sectors: Total sector count (multiply by 512 for bytes)
- Size: Human-readable partition size
- Type: Descriptive partition type name
- Type-UUID: GPT partition type identifier (standardized across systems)
- UUID: Unique filesystem identifier (used in /etc/fstab with UUID=...)
- Partition GUID: Globally unique partition identifier
Expert Mode Features:
- x command: Enter expert mode for advanced operations
- f command: Fix partition ordering (sorts partition table entries)
- r command: Return to main menu from expert mode
- v command: Verify partition table consistency and alignment
- i command: Change disk GUID (GPT only)
- d/D commands: Display raw sector data for debugging
- Unused sectors: Small amount of space reserved for alignment and metadata
- Signature detection: Verification shows existing filesystems on partitions