Disk_partitioning
Chapter 12: Disk Partitioning and Tools
Section titled “Chapter 12: Disk Partitioning and Tools”Overview
Section titled “Overview”This chapter covers disk partitioning tools and techniques for managing storage in Linux systems.
12.1 Partitioning Concepts
Section titled “12.1 Partitioning Concepts”MBR vs GPT
Section titled “MBR vs GPT”┌─────────────────────────────────────────────────────────────────────────┐│ PARTITION TYPES │├─────────────────────────────────────────────────────────────────────────┤│ ││ MBR (Master Boot Record): ││ ┌─────────────────────────────────────────────────────────────────┐ ││ │ • Max 4 primary partitions (or 3 + 1 extended) │ ││ │ • Max 2TB disk size limit │ ││ │ • Boot code in first sector (512 bytes) │ ││ │ • Legacy BIOS boot │ ││ │ • 32-bit LBA for addressing │ ││ └─────────────────────────────────────────────────────────────────┘ ││ ││ GPT (GUID Partition Table): ││ ┌─────────────────────────────────────────────────────────────────┐ ││ │ • Max 128 partitions (default) │ ││ │ • Max 256TB disk size (theoretical) │ ││ │ • GUID-based unique identifiers │ ││ │ • UEFI required for boot │ ││ │ • CRC32 checksums for integrity │ ││ │ • Backup GPT header at end of disk │ ││ └─────────────────────────────────────────────────────────────────┘ ││ │└─────────────────────────────────────────────────────────────────────────┘12.2 Partitioning Tools
Section titled “12.2 Partitioning Tools”fdisk (MBR)
Section titled “fdisk (MBR)”# List partitionssudo fdisk -lsudo fdisk -l /dev/sdb
# Partition disksudo fdisk /dev/sdb
# Commands:# n - new partition# p - primary partition# e - extended partition# l - list partition types# t - change partition type# d - delete partition# w - write and quit# q - quit without saving# p - print partition tableparted (GPT)
Section titled “parted (GPT)”# Interactive modesudo parted /dev/sdb
# Commands:# mklabel gpt# mklabel msdos# mkpart primary ext4 0% 100%# mkpart primary xfs 1MiB 100%# rm 1# print# quit
# Scriptedsudo parted -s /dev/sdb mklabel gptsudo parted -s /dev/sdb mkpart primary ext4 0% 100%gdisk (GPT)
Section titled “gdisk (GPT)”# GPT partitioningsudo gdisk /dev/sdb
# Commands:# o - create new GPT# n - new partition# w - write# q - quit# p - print# i - partition info12.3 Partition Examples
Section titled “12.3 Partition Examples”Creating Partitions with fdisk
Section titled “Creating Partitions with fdisk”sudo fdisk /dev/sdb
# Example session:# n (new)# p (primary)# 1 (partition number)# First sector: Enter (default)# Last sector: +10G# w (write)Creating Partitions with parted
Section titled “Creating Partitions with parted”# Scripted partitioningsudo parted -s /dev/sdb mklabel gptsudo parted -s /dev/sdb mkpart primary ext4 0% 1GiBsudo parted -s /dev/sdb mkpart primary ext4 1GiB 100%Setting Partition Types
Section titled “Setting Partition Types”# Set partition type (fdisk)# t command# 1 - Linux# 5 - Extended# 7 - HPFS/NTFS/exFAT# 8 - Linux LVM# a - Boot flag
# Set bootable flag# a command12.4 Partprobe
Section titled “12.4 Partprobe”# Notify kernel of partition changessudo partprobe /dev/sdb
# Without writing to disksudo partprobe -s
# For specific partitionsudo partprobe -s /dev/sdb112.5 Partition Layout
Section titled “12.5 Partition Layout”Common Partition Layouts
Section titled “Common Partition Layouts”# BIOS/MBR Layout:# /dev/sda1 - /boot (512MB-1GB)# /dev/sda2 - / (root, 20-30GB)# /dev/sda3 - /home (remaining)# /dev/sda4 - Extended partition# /dev/sda5 - swap (2x RAM)
# UEFI/GPT Layout:# /dev/sda1 - /boot/efi (ESP, 512MB, EF00 type)# /dev/sda2 - / (root)# /dev/sda3 - /home# /dev/sda4 - swapArch Linux Installation Example
Section titled “Arch Linux Installation Example”# Common partition layout:# /boot - 512MB to 1GB (EFI System Partition)# / - 20-30GB (root)# /home - Remaining (user data)# swap - 2x RAM (optional with btrfs)
# Example with fdisk:# n, p, 1, Enter, +512M # /boot/efi# n, p, 2, Enter, +30G # /# n, p, 3, Enter, Enter # /home# t, 1, 1 # Set ESP type (EF00)12.6 Interview Questions
Section titled “12.6 Interview Questions”Q: What is the difference between MBR and GPT?A: MBR: max 4 partitions, 2TB limit, legacy GPT: max 128 partitions, 256TB+, UEFI
Q: How do you create a partition in Linux?A: fdisk /dev/sdb, then n for new partition
Q: What is partprobe?A: Notifies kernel of partition changes without reboot
Q: What is an extended partition?A: Container for logical partitions (MBR only)Summary
Section titled “Summary”- MBR: Legacy, 4 primary, 2TB limit
- GPT: Modern, 128 partitions, UEFI
- Tools: fdisk, parted, gdisk
Next Chapter
Section titled “Next Chapter”Chapter 13: LVM - Logical Volume Manager
Last Updated: February 2026