Understanding the cfdisk Interface:
- Header Information: Shows disk path, total size, sector count, and label type (GPT or DOS)
- Partition Table: Clear visual display of all partitions with sizes and types
- Selected Row: Highlighted partition (indicated by >>) is the current selection
- Bottom Menu: Context-sensitive menu showing available operations
- Navigation: Use arrow keys to move between partitions and menu items
- Color Coding: Different partition types may be shown in different colors
- Real-time Display: Interface updates immediately as you make changes
Basic Navigation Keys:
Creating New Partition Process:
- Select Free Space: Use arrow keys to highlight free space area
- Choose "New": Navigate to [New] menu option and press Enter
- Specify Size: Enter desired size using units (G, M, T) or press Enter for maximum
- Size Format: Can use absolute (100G), relative (+100G), or percentage formats
- Default Type: New partitions default to "Linux filesystem" type
- Automatic Alignment: cfdisk automatically aligns partitions to optimal boundaries
- Immediate Display: New partition appears in table immediately
- Not Yet Written: Changes remain in memory until you select "Write"
Safe Deletion Process:
- Visual Selection: Clearly see which partition is selected before deletion
- Confirmation Prompt: Must type "yes" to confirm (prevents accidental deletion)
- Immediate Update: Deleted partition becomes "Free space" in the display
- Reversible (before Write): Can quit without saving if you delete wrong partition
- Partition Numbering: Numbers don't automatically shift (sdb3 remains sdb3)
- Data Intact: Deletion only removes partition table entry, data still exists on disk
- Unmount Required: Should unmount partition before deletion to prevent data corruption
- Menu Changes: Available menu options update based on selection (partition vs free space)
Common Partition Types in cfdisk:
- Linux filesystem: Standard data partition (ext4, xfs, btrfs, etc.)
- Linux swap: Virtual memory swap space
- Linux LVM: Physical volume for Logical Volume Manager
- Linux RAID: Software RAID member partition
- EFI System: Boot partition for UEFI systems (typically 512MB FAT32)
- Linux home: Designated for /home directory
- Linux root (x86-64): Root filesystem for x86-64 systems
- Microsoft basic data: NTFS or FAT partitions for Windows compatibility
- BIOS boot: Small partition for GRUB on GPT disks with BIOS boot
Understanding Write Operation:
- In-Memory Changes: All modifications are stored in memory until you Write
- Safety Confirmation: Must type "yes" exactly - "y" or "Yes" won't work
- Point of No Return: Once confirmed, changes are immediately committed to disk
- ioctl() Call: Kernel is notified to re-read the partition table
- Disk Sync: Ensures all changes are physically written to disk
- Exit After Write: cfdisk typically exits after successful write
- Kernel Update: May require partprobe or reboot for kernel to see changes
- Check Results: Verify with lsblk or fdisk -l after writing
Partition Resizing Considerations:
- Adjacent Free Space: Can only expand into immediately adjacent free space
- Partition Table Only: Resizing in cfdisk only changes partition boundaries
- Filesystem Not Resized: Must separately resize filesystem after writing changes
- Expanding Filesystems: Use resize2fs for ext4, xfs_growfs for XFS
- Shrinking Risk: Shrinking is dangerous - can lose data if filesystem doesn't fit
- Backup First: Always backup data before any resize operation
- Unmount Recommended: Best practice to unmount partition before resizing
- Start Sector Fixed: Resize typically only changes end sector, keeping start sector
Label Type Selection:
- GPT (Recommended): Modern standard, supports disks > 2TB, up to 128 partitions, built-in redundancy
- DOS/MBR: Legacy format, max 2TB disk size, limited to 4 primary partitions
- SGI: Silicon Graphics IRIX systems (rare, specialized use)
- Sun: Sun Microsystems systems (Solaris, rare)
- -z Flag: Ignores existing partition table, starts fresh (dangerous if used on wrong disk!)
- UEFI Requirement: Modern UEFI systems require GPT for boot drives
- Automatic GUID: GPT creates unique disk identifier automatically
- Protective MBR: GPT includes legacy MBR to prevent old tools from corrupting disk
Key Commands Reference:
- n (New): Create new partition in free space
- d (Delete): Remove selected partition (prompts for confirmation)
- t (Type): Change partition type/filesystem identifier
- r (Resize): Expand or shrink partition boundaries
- W (Write): Save changes to disk (uppercase W required as safety feature)
- q (Quit): Exit without saving changes
- b (Bootable): Toggle bootable flag (MBR only, not GPT)
- s (Sort): Reorganize partition table entries by start sector
- u (Dump): Export partition layout to sfdisk script format
- x (Extra): Toggle display of additional partition information
Safe Exit Process:
- Change Detection: cfdisk tracks whether you've made any modifications
- Confirmation Prompt: Only appears if you've made changes that haven't been written
- All Changes Lost: Selecting "Yes" discards all modifications made in current session
- No Disk Changes: Original partition table remains completely unchanged
- No Confirmation: If no changes made, quit exits immediately without prompting
- ESC Key: Pressing ESC is equivalent to selecting Quit
- Safety Feature: This is your undo button - use it if you make mistakes
- Start Fresh: Can immediately relaunch cfdisk to try again
Partition Table Type Options:
- -t gpt: Force GPT partition table (best for modern systems and large disks)
- -t dos: Force DOS/MBR partition table (legacy systems, max 2TB)
- -t sgi: Force SGI partition table (IRIX systems)
- -t sun: Force Sun partition table (Solaris systems)
- No -t flag: cfdisk auto-detects existing label or prompts for selection
- Size Considerations: Disks > 2TB require GPT
- Boot Requirements: UEFI systems typically require GPT
- Legacy Systems: Old BIOS systems may need DOS/MBR