Disk Partitioning & File Systems: Complete Windows & Linux Storage Guide

Ever wondered why your 2 TB external drive shows only 2 TB on Windows despite being formatted as MBR, or why Linux won’t boot after resizing partitions? Understanding disk partitioning, file system architecture, and storage management prevents data loss disasters and empowers you to troubleshoot 80% of storage-related issues by mastering fundamental concepts that govern how operating systems organize data. Whether you’re setting up dual-boot systems, configuring enterprise servers, or recovering corrupted filesystems, this comprehensive guide provides hands-on techniques for Windows and Linux storage administration.

Reading Time: 18 minutes

What You’ll Learn:

  • File system fundamentals: NTFS, ext4, FAT32 compatibility and use cases
  • Disk components: partitions, volumes, clusters, and allocation units
  • MBR vs GPT partition tables: size limits, UEFI requirements, and conversion
  • Windows partitioning: Disk Management GUI and DiskPart CLI automation
  • Linux partitioning: parted, fdisk, and formatting with mkfs
  • Mounting filesystems: Windows drive letters vs Linux mount points and fstab
  • Virtual memory management: paging files, swap partitions, and performance tuning
  • Data recovery: chkdsk, fsck, journaling, and self-healing filesystems
  • Hard links vs symbolic links: metadata structures and file references

Prerequisites

Windows System:

  • Windows 10/11 with administrator privileges
  • Secondary storage device (USB drive or spare disk) for practice
  • Backup critical data before experimenting with disk operations

Linux System:

  • Ubuntu 20.04+, Debian 11+, or similar distribution
  • Sudo/root access for disk management
  • Spare disk or USB drive for partitioning practice

⚠ Critical Warning: Disk partitioning and formatting operations are destructive and irreversible. Always backup data before modifying partitions, and practice on test systems or spare drives before working with production data.


File System Fundamentals

What Is a File System?

A file system provides the organizational structure enabling operating systems to store, retrieve, and manage files on storage devices. Without a file system, a hard drive would be an unorganized stream of bits—the OS wouldn’t know where one file ends and another begins, how to locate files, or how to manage available space.​

File systems implement:

  • File naming conventions: Maximum length, allowed characters, case sensitivity
  • Directory structure: Hierarchical organization of files and folders
  • Metadata storage: File sizes, timestamps, permissions, ownership
  • Space allocation: Tracking used and free storage blocks
  • Data integrity: Journaling, checksums, error detection and correction

Common File Systems

Windows File Systems:

NTFS (New Technology File System):

  • Native Windows file system since Windows NT 3.1 (1993)
  • Maximum file size: 16 EB (exabytes) theoretical, 16 TB practical
  • Maximum volume size: 256 TB (Windows limits)
  • Features: Journaling, compression, encryption (EFS), file permissions (ACLs), quotas
  • Compatibility: Windows native, Linux read/write with ntfs-3g driver, macOS read-only​
  • Best for: System drives, internal storage, enterprise applications

FAT32 (File Allocation Table 32):

  • Legacy file system from Windows 95 era
  • Maximum file size: 4 GB (major limitation)​
  • Maximum volume size: 32 GB (Windows format limit), 2 TB (theoretical)​
  • Features: Minimal—no permissions, journaling, or compression
  • Compatibility: Universal—Windows, Linux, macOS, game consoles, cameras​​
  • Best for: USB flash drives, SD cards, devices requiring cross-platform compatibility​

exFAT (Extended FAT):

  • Microsoft’s modern replacement for FAT32
  • Maximum file size: 16 EB
  • Maximum volume size: 128 PB
  • Features: Large file support, low overhead, no journaling
  • Compatibility: Windows, macOS, modern Linux (requires exfat-fuse)
  • Best for: Large external drives, SD cards >32 GB, video storage

Linux File Systems:

ext4 (Fourth Extended Filesystem):

  • Default Linux file system since 2008​
  • Maximum file size: 16 TB
  • Maximum volume size: 1 EB
  • Features: Journaling, delayed allocation, extents (improved performance), fsck speed improvements
  • Compatibility: Linux only—Windows/macOS require third-party drivers​
  • Best for: Linux system drives, servers, databases

ext3 / ext2:

  • Predecessors to ext4 with fewer features​
  • ext3 added journaling over ext2
  • Largely superseded by ext4 but still supported

XFS:

  • High-performance 64-bit journaling file system
  • Excellent for large files and parallel I/O
  • Used by Red Hat Enterprise Linux by default
  • Difficult to shrink volumes (only expansion supported)

File System Comparison

FeatureNTFS ext4 FAT32 ​exFAT 
Max File Size16 TB16 TB4 GB16 EB
Max Volume256 TB1 EB2 TB128 PB
JournalingYesYesNoNo
PermissionsACLsPOSIXNoneNone
CompressionYesNoNoNo
EncryptionEFSdm-cryptNoNo
WindowsNativeThird-partyNativeNative
Linuxntfs-3gNativeNativeexfat-fuse
macOSRead-onlyThird-partyNativeNative

✓ Choosing the Right File System:

  • Windows system drive: NTFS (required for modern Windows)
  • Linux system drive: ext4 (default and recommended)
  • External drives <32 GB: FAT32 (universal compatibility)
  • External drives >32 GB: exFAT (large files, cross-platform) or NTFS (Windows-only)
  • Dual-boot shared partition: NTFS with Linux ntfs-3g driver (read/write both OSes)

Disk Components

Partitions and Volumes

Partition:
A partition is a logical division of a physical disk, creating separate regions that the operating system treats as independent storage units. One physical hard drive can contain multiple partitions—for example, a 1 TB drive might have a 500 GB partition for Windows, 450 GB partition for Linux, and 50 GB recovery partition.​

Volume:
A volume is a formatted partition with an assigned file system, making it accessible for storing files. The distinction: partitions define boundaries, volumes contain usable filesystems.​

Common Partition Layouts:

Single-OS Windows System:

Disk 0 (500 GB)
├── EFI System Partition (100 MB, FAT32)
├── Windows Recovery (500 MB, NTFS)
└── Windows C: Drive (499.4 GB, NTFS)

Dual-Boot Windows/Linux System:

Disk 0 (1 TB)
├── EFI System Partition (512 MB, FAT32)
├── Windows C: Drive (400 GB, NTFS)
├── Linux Root / (50 GB, ext4)
├── Linux Swap (16 GB, swap)
└── Shared Data D: (533.5 GB, NTFS)

Partition Tables: MBR vs GPT

Partition tables store information about how a disk is divided—partition locations, sizes, types, and boot flags. Two standards dominate: legacy MBR and modern GPT.

MBR (Master Boot Record):

MBR is the traditional partitioning scheme dating to 1983 (MS-DOS 2.0), slowly being phased out but still widely used.

MBR Specifications:

  • Maximum disk size: 2 TB
  • Maximum partitions: 4 primary partitions​​
  • Extended partitions: Use 1 primary slot for extended partition containing unlimited logical drives
  • Boot support: Legacy BIOS only
  • Redundancy: Single partition table at beginning of disk—corruption renders disk unbootable
  • Partition table location: First 512 bytes of disk (sector 0)

MBR Limitations:

Physical Disk (3 TB capacity)
├── Partition 1 (2 TB addressable) ← MBR limit
└── Remaining 1 TB UNUSABLE ← Cannot address beyond 2 TB

GPT (GUID Partition Table):

GPT is the modern standard supporting UEFI firmware, large disks, and virtually unlimited partitions.

GPT Specifications:

  • Maximum disk size: 9.4 ZB (zettabytes) = 9.4 billion TB
  • Maximum partitions: 128 partitions (Windows implementation), theoretically unlimited​​
  • Boot support: UEFI firmware (modern PCs), some legacy BIOS with protective MBR
  • Redundancy: Primary partition table at disk start, backup copy at disk end
  • Data protection: CRC32 checksums detect partition table corruption
  • 64-bit addressing: Supports disks beyond 2 TB

GPT vs MBR Comparison:

FeatureMBR GPT 
Max Disk Size2 TB 9.4 ZB 
Partitions4 primary (or 3 + extended) 128 (Windows), unlimited 
FirmwareLegacy BIOS only UEFI (preferred), legacy with protective MBR 
Boot SpeedSlower BIOS initialization Faster UEFI boot 
RedundancySingle partition table Primary + backup tables 
Data SafetyNo error detection CRC32 checksums 
Secure BootNot supportedSupported with UEFI 
Best ForLegacy systems, <2 TB disks Modern systems, >2 TB disks 

When to Use Each:

  • Use GPT: New installations, disks >2 TB, UEFI systems, modern Windows 10/11, enhanced data protection needed
  • Use MBR: Legacy BIOS systems requiring boot compatibility, disks <2 TB, older hardware without UEFI

⚠ Conversion Warning: Converting between MBR and GPT requires deleting all partitions—backup all data first.

Clusters (Allocation Units)

Clusters (also called allocation units) represent the smallest storage unit a file system can allocate. Even a 1 KB file consumes an entire cluster—if the cluster size is 4 KB, 3 KB is wasted.​

Cluster Size Trade-offs:

Small Clusters (4 KB):

  • ✓ Minimal wasted space for small files
  • ✓ Efficient for many small files (documents, web content)
  • ✗ Higher overhead—more clusters require more metadata
  • ✗ Increased fragmentation on spinning disks

Large Clusters (64 KB+):

  • ✓ Lower overhead—fewer clusters to manage
  • ✓ Better performance for large sequential files (video, databases)
  • ✗ Significant wasted space for small files
  • ✗ A 1 KB text file wastes 63 KB with 64 KB clusters

Example Calculation:

1,000 files averaging 5 KB each on 4 KB cluster filesystem:
- Used space: 5 KB × 1,000 = 5,000 KB (5 MB)
- Actual allocation: 8 KB × 1,000 = 8,000 KB (8 MB)
- Wasted space: 3 MB (37.5% overhead)

Same files on 32 KB cluster filesystem:
- Used space: 5,000 KB (5 MB)
- Actual allocation: 32 KB × 1,000 = 32,000 KB (32 MB)
- Wasted space: 27 MB (84% overhead)

✓ Best Practice: Use default cluster sizes unless specific requirements exist—NTFS defaults to 4 KB for volumes <16 TB, ext4 defaults to 4 KB.​


Windows Disk Partitioning

GUI Method: Disk Management

Opening Disk Management:

  1. Right-click “This PC” → Manage → Disk Management
  2. Or: Win+X → Disk Management
  3. Or: Run diskmgmt.msc

Creating New Partition:

  1. Identify unallocated space: Black bar labeled “Unallocated”
  2. Right-click unallocated space: New Simple Volume
  3. Volume Size: Specify size in MB (default uses all space)
  4. Drive Letter: Assign letter (D:, E:, etc.) or mount to empty NTFS folder
  5. Format settings:
    • File system: NTFS (recommended) or FAT32
    • Allocation unit size: Default (4096 bytes for NTFS)
    • Volume label: Descriptive name (e.g., “Data Drive”)
    • Quick Format: Check for speed (recommended unless testing for bad sectors)
  6. Finish: Windows creates and formats partition

Shrinking Existing Volume:

1. Right-click volume (e.g., C:) → Shrink Volume
2. Windows calculates available shrink space
3. Enter amount to shrink in MB
4. Click Shrink → Creates unallocated space
5. Create new volume in freed space

Extending Volume:

1. Ensure unallocated space is immediately adjacent to volume
2. Right-click volume → Extend Volume
3. Specify amount to add (or use all available)
4. Finish → Volume expands without data loss

⚠ Limitation: Disk Management cannot shrink volumes beyond immovable system files—use third-party tools (EaseUS, MiniTool) for advanced resizing.

CLI Method: DiskPart

DiskPart provides scripting capabilities for automated disk management.​

Basic DiskPart Workflow:

# Open DiskPart (requires Administrator)
diskpart

# List all physical disks
list disk

# Output example:
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 476 GB 0 B *
Disk 1 Online 931 GB 931 GB

# Select disk (CAUTION: Double-check disk number!)
select disk 1

# Remove all partitions (DESTRUCTIVE!)
clean

# Convert to GPT (or use 'convert mbr' for MBR)
convert gpt

# Create new partition using all space
create partition primary

# Or create partition with specific size (50 GB)
create partition primary size=51200

# Select newly created partition
select partition 1

# Mark as active/bootable (MBR only, for boot partitions)
active

# Format with NTFS (quick format)
format fs=ntfs label="Data Drive" quick

# Assign drive letter
assign letter=E

# Exit DiskPart
exit

Quick vs Full Format:

Quick Format:

  • Removes file table pointers only
  • Completes in seconds
  • Does not check for bad sectors
  • Recommended for new/reliable drives​

Full Format:

  • Writes zeros to entire volume
  • Scans for bad sectors and marks unusable areas
  • Takes hours on large drives
  • Recommended for questionable/used drives​

Advanced DiskPart Operations:

# List all partitions on selected disk
list partition

# Delete partition (DESTRUCTIVE!)
select partition 2
delete partition

# Create EFI system partition (GPT boot)
create partition efi size=100
format fs=fat32 quick
assign letter=S

# Create multiple partitions with script
(echo select disk 1
echo clean
echo convert gpt
echo create partition primary size=102400
echo format fs=ntfs quick
echo assign letter=D
echo create partition primary
echo format fs=ntfs quick
echo assign letter=E
) | diskpart

Linux Disk Partitioning

Listing Block Devices

lsblk (List Block Devices):

# Display tree view of all block devices
lsblk

# Output example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 400G 0 part /
└─sda3 8:3 0 16 G 0 part [SWAP]
sdb 8:16 1 29.3G 0 disk
└─sdb1 8:17 1 29.3G 0 part /media/usb

# Show filesystem types and UUIDs
lsblk -f

# Output with sizes in human-readable format
lsblk -h

parted (List All Disks):

# Display partition information for all disks
sudo parted -l

# Output example:
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 boot, esp
2 538MB 430GB 429GB ext4
3 430GB 447GB 17.2GB linux-swap(v1) swap

Partitioning with parted

parted provides both interactive and command-line interfaces for GPT and MBR partition management.​

Interactive parted Session:

# Start parted on specific disk
sudo parted /dev/sdb

# parted interactive prompt appears
(parted) print # Show current partition table

# Create new GPT partition table (DESTROYS ALL DATA!)
(parted) mklabel gpt

# Create partition from 1MB to 5GB
(parted) mkpart primary ext4 1MB 5GB

# Create partition using remaining space
(parted) mkpart primary ext4 5GB 100%

# Set boot flag on partition 1 (EFI system partition)
(parted) set 1 boot on

# Remove partition
(parted) rm 2

# Exit parted
(parted) quit

Command-Line parted (Scripting):

# Create GPT table and partition in single command
sudo parted /dev/sdb --script mklabel gpt mkpart primary ext4 1MB 100%

# Create multiple partitions
sudo parted /dev/sdb --script \
mklabel gpt \
mkpart primary fat32 1MB 512MB \
set 1 boot on \
mkpart primary ext4 512MB 50GB \
mkpart primary linux-swap 50GB 66GB \
mkpart primary ext4 66GB 100%

Partitioning with fdisk

fdisk is the traditional Linux partition editor, primarily for MBR but supports GPT.​

Interactive fdisk Session:

# Start fdisk on disk
sudo fdisk /dev/sdb

# fdisk interactive prompt
Command (m for help): m # Show help menu
Command (m for help): p # Print partition table

# Create new GPT table
Command (m for help): g

# Create new partition
Command (m for help): n
Partition number (1-128, default 1): 1
First sector (default 2048): [Enter]
Last sector (default xxxxx): +5G # 5 GB partition

# Change partition type (optional)
Command (m for help): t
Partition number (1, default 1): 1
Partition type (type L to list all): 19 # Linux swap

# Print partition table to verify
Command (m for help): p

# Write changes to disk (IRREVERSIBLE!)
Command (m for help): w

fdisk Partition Types:

1   EFI System
19 Linux swap
20 Linux filesystem (default)
11 Microsoft basic data (NTFS/FAT32)

✓ Best Practice: Always run sudo fdisk -l or lsblk before partitioning to confirm correct disk device name—mistaking /dev/sda for /dev/sdb destroys wrong disk’s data.


Formatting File Systems

Windows Formatting

GUI Format:

1. Disk Management → Right-click partition → Format
2. Select file system (NTFS/FAT32/exFAT)
3. Allocation unit size: Default
4. Volume label: Descriptive name
5. Quick Format: Check (unless testing for bad sectors)
6. OK → Format begins

Command-Line Format:

# Format E: drive as NTFS with label
format E: /FS:NTFS /V:DataDrive /Q

# Format flags:
# /FS:filesystem - NTFS, FAT32, or exFAT
# /V:label - Volume label
# /Q - Quick format
# /A:size - Cluster size (4096, 8192, etc.)

# Format with specific cluster size (8 KB clusters)
format E: /FS:NTFS /V:BigFiles /A:8192 /Q

Linux Formatting (mkfs)

mkfs (Make Filesystem):

# Format as ext4 (most common)
sudo mkfs -t ext4 /dev/sdb1

# Alternative syntax
sudo mkfs.ext4 /dev/sdb1

# Format with label
sudo mkfs.ext4 -L "Data Partition" /dev/sdb1

# Format with specific block size (4 KB default)
sudo mkfs.ext4 -b 4096 /dev/sdb1

# Format as ext3
sudo mkfs.ext3 /dev/sdb2

# Format as FAT32 (for USB drives)
sudo mkfs.vfat -F 32 /dev/sdb1

# Format as exFAT (requires exfat-utils package)
sudo mkfs.exfat /dev/sdb1

# Format as NTFS (requires ntfs-3g package)
sudo mkfs.ntfs -f /dev/sdb1 # -f = fast format

Creating Swap Partition:

# Format partition as swap
sudo mkswap /dev/sdb2

# Label swap partition
sudo mkswap -L "Swap" /dev/sdb2

# Enable swap immediately
sudo swapon /dev/sdb2

# Verify swap is active
swapon --show
free -h

Mounting and Unmounting

Windows Drive Letters

Windows automatically assigns drive letters (C:, D:, E:, etc.) when detecting formatted partitions. USB drives receive letters automatically on insertion.​

Manual Drive Letter Assignment:

1. Disk Management → Right-click volume
2. Change Drive Letter and Paths
3. Change → Select new letter → OK

Safely Removing Drives:

1. System tray → Click "Safely Remove Hardware" icon
2. Select device → Click Eject
3. Wait for "Safe to Remove Hardware" message
4. Physically disconnect device

⚠ Warning: Removing USB drives without ejecting risks data corruption—Windows caches writes for performance, and ejecting flushes pending operations to disk.​

Linux Manual Mounting

Linux requires explicit mount commands to attach filesystems to the directory tree.​

Temporary Mount:

# Create mount point (directory)
sudo mkdir /mnt/usb_drive

# Mount partition to mount point
sudo mount /dev/sdb1 /mnt/usb_drive

# Access files
ls /mnt/usb_drive

# Unmount when finished
sudo umount /mnt/usb_drive

Mount with Specific Options:

# Mount read-only
sudo mount -o ro /dev/sdb1 /mnt/usb_drive

# Mount with specific filesystem type
sudo mount -t ntfs-3g /dev/sdb1 /mnt/windows_drive

# Mount with permissions (for FAT32/NTFS without native permissions)
sudo mount -o uid=1000,gid=1000,umask=002 /dev/sdb1 /mnt/shared

Viewing Mounted Filesystems:

# Show all mounted filesystems
mount

# Human-readable disk space usage
df -h

# Output example:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 400G 120G 260G 32% /
/dev/sda1 511M 5.3M 506M 2% /boot/efi
/dev/sdb1 29G 1.2G 28G 5% /mnt/usb_drive

Permanent Mounting with /etc/fstab

/etc/fstab (filesystem table) defines filesystems to mount automatically at boot.​

fstab Format:

<device>  <mount_point>  <fs_type>  <options>  <dump>  <pass>

fstab Fields Explained:

  1. Device: UUID, LABEL, or /dev/sdX identifier​
  2. Mount point: Directory where filesystem appears​
  3. Filesystem type: ext4, ntfs-3g, vfat, swap​
  4. Mount options: defaults, rw, noexec, user​
  5. Dump: 0 = no backup, 1 = backup with dump utility​
  6. Pass: fsck order—0 = no check, 1 = root (first), 2 = other filesystems​

Finding UUID:

# List all UUIDs
sudo blkid

# Output example:
/dev/sda1: UUID="A1B2-C3D4" TYPE="vfat" PARTLABEL="EFI System"
/dev/sda2: UUID="12345678-90ab-cdef-1234-567890abcdef" TYPE="ext4"
/dev/sdb1: UUID="ABCD-1234" TYPE="vfat"

Adding Entry to fstab:

# Edit fstab (use nano or vim)
sudo nano /etc/fstab

# Add line for external drive (using UUID recommended over /dev/sdX)
UUID=ABCD-1234 /mnt/usb_drive vfat defaults,uid=1000,gid=1000 0 2

# Save file (Ctrl+O, Enter, Ctrl+X in nano)

# Test fstab without rebooting
sudo mount -a

# Verify mount
df -h | grep usb_drive

Common Mount Options:

  • defaults: rw, suid, dev, exec, auto, nouser, async (standard defaults)
  • rw / ro: Read-write or read-only
  • noexec: Prevent executable files from running (security for data partitions)
  • user: Allow non-root users to mount
  • auto / noauto: Mount automatically at boot or require manual mount
  • nofail: Continue boot even if device missing (important for external drives)

Example fstab Entries:

# Root filesystem
UUID=12345-... / ext4 errors=remount-ro 0 1

# Boot partition
UUID=A1B2-... /boot/efi vfat umask=0077 0 1

# Swap partition
UUID=67890-... none swap sw 0 0

# External data drive (may be disconnected at boot)
UUID=CDEF-... /mnt/backup ntfs-3g defaults,nofail 0 2

# Shared NTFS partition (dual-boot)
UUID=FEDC-... /mnt/shared ntfs-3g defaults,uid=1000,gid=1000 0 2

Virtual Memory, Paging, and Swap

Virtual Memory Concepts

Virtual memory extends available RAM by using disk space as supplemental memory. The operating system manages mapping between virtual memory addresses (what programs see) and physical memory addresses (actual RAM locations).​

Benefits:

  • Programs use more memory than physically installed
  • Multiple large applications run simultaneously
  • Memory isolation between processes (security)
  • OS can swap idle processes to disk, freeing RAM for active tasks

Performance Impact:

  • Disk access is 100-1000x slower than RAM
  • Excessive swapping (“thrashing”) degrades performance severely
  • SSDs reduce performance penalty compared to HDDs

Windows Paging File

pagefile.sys is a hidden system file storing inactive memory pages when RAM fills.​

Viewing/Configuring Paging File:

1. Control Panel → System → Advanced system settings
2. Performance section → Settings
3. Advanced tab → Virtual memory → Change
4. Uncheck "Automatically manage paging file size"
5. Select drive (usually C:)
6. Custom size:
- Initial size (MB): 1× RAM for systems with ≥8 GB
- Maximum size (MB): 2-3× RAM
7. Set → OK → Restart required

PowerShell Management:

# View current paging file configuration
Get-CimInstance -ClassName Win32_PageFileUsage

# Set paging file size (requires restart)
$PageFile = Get-CimInstance -ClassName Win32_PageFileSetting
$PageFile.InitialSize = 16384 # 16 GB
$PageFile.MaximumSize = 32768 # 32 GB
Set-CimInstance -InputObject $PageFile

✓ Guideline: For 64-bit Windows systems with ≥8 GB RAM, set paging file to 1× RAM size. Systems with 16 GB+ RAM may use smaller paging files or none (risky—some applications require it).​

Linux Swap Space

Linux uses dedicated swap partitions or swap files instead of pagefile integration.​

Creating Swap Partition:

# 1. Create partition with fdisk/parted (type 19 = Linux swap)
sudo fdisk /dev/sdb
# n → new partition → +16G → t → 19 → w

# 2. Format as swap
sudo mkswap /dev/sdb2

# 3. Enable swap
sudo swapon /dev/sdb2

# 4. Verify
swapon --show
free -h

# Output:
total used free
Mem: 15Gi 8.0Gi 7.0Gi
Swap: 16Gi 0Bi 16Gi

Creating Swap File (Alternative):

# Create 8 GB swap file
sudo fallocate -l 8G /swapfile

# Set permissions (critical for security)
sudo chmod 600 /swapfile

# Format as swap
sudo mkswap /swapfile

# Enable swap
sudo swapon /swapfile

# Verify
swapon --show

Permanent Swap Configuration:

# Add to /etc/fstab for automatic activation at boot
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# Or for swap partition:
echo 'UUID=<swap-uuid> none swap sw 0 0' | sudo tee -a /etc/fstab

Managing Swap:

# Disable swap
sudo swapoff /dev/sdb2

# Disable all swap
sudo swapoff -a

# Re-enable all swap from fstab
sudo swapon -a

# View swap usage
free -h

✓ Swap Sizing Guidelines:

  • <2 GB RAM: 2× RAM
  • 2-8 GB RAM: 1× RAM
  • >8 GB RAM: 4-8 GB swap (or match RAM for hibernation support)
  • Servers: Minimal swap (2-4 GB) to prevent thrashing

Windows: Master File Table (MFT)

NTFS stores file metadata in the Master File Table—a database containing at least one entry per file.​

MFT Record Contents:

  • Filename and attributes (read-only, hidden, system, compressed)
  • Timestamps (created, modified, accessed)
  • File size and location (cluster addresses)
  • Security descriptor (permissions ACL)
  • Compression and encryption flags
  • For small files (<900 bytes): Actual file data stored in MFT record

Viewing MFT with Orca.exe:

Download Windows SDK → Install MSI Tools component → Run Orca.exe to inspect MFT structure.​

Windows Links

Shortcuts (.lnk files):

  • Separate file pointing to target’s filename/path
  • OS does not treat as substitute for original
  • Breaks if target moves or renames
  • Created: Right-click → Create Shortcut

Symbolic Links (Soft Links):

  • OS treats as transparent substitute for original
  • Breaks if target moves or renames
  • Supports files and directories
# Create directory symbolic link
mklink /D C:\Users\Public\SharedFolder "D:\Shared Data"

# Create file symbolic link
mklink C:\Users\Public\Document.txt "D:\Files\Document.txt"

Hard Links:

  • Multiple filenames pointing to same MFT record
  • Survives target renames and moves
  • Deleting original doesn’t remove hard link
  • Cannot span volumes
# Create hard link
mklink /H C:\Backup\File.txt C:\Original\File.txt

Linux Inodes and Links

Inodes:
Linux stores file metadata in inodes—data structures containing everything about a file except its name and actual data.​

Inode Contents:

  • File size
  • Owner UID and group GID
  • Permissions (rwx)
  • Timestamps (access, modify, change)
  • Hard link count
  • Pointer to data blocks
# View inode numbers
ls -li

# Output:
1234567 -rw-r--r-- 2 user group 4096 Jan 30 10:00 file.txt

Hard Links:
Multiple directory entries pointing to same inode.​

# Create hard link
ln /home/user/file.txt /backup/file.txt

# Verify (same inode number, link count = 2)
ls -li /home/user/file.txt /backup/file.txt

1234567 -rw-r--r-- 2 user group 4096 Jan 30 10:00 /home/user/file.txt
1234567 -rw-r--r-- 2 user group 4096 Jan 30 10:00 /backup/file.txt

Symbolic Links (Soft Links):
Separate file containing path to target.​

# Create symbolic link
ln -s /home/user/file.txt /tmp/file_symlink

# Verify (different inode, 'l' type, shows target)
ls -li /tmp/file_symlink

7654321 lrwxrwxrwx 1 user group 20 Jan 30 10:15 /tmp/file_symlink -> /home/user/file.txt

Hard Link vs Symbolic Link:

FeatureHard Link ​Symbolic Link ​
TargetPoints to inode (file record)Points to pathname
Survives renameYesNo (breaks)
Survives deletionYes (until all links deleted)No (becomes dangling)
Cross-filesystemNoYes
DirectoriesNot allowedYes
Visible differenceAppears as regular fileShows link arrow, ‘l’ type

Disk Usage Monitoring

Windows Disk Management

GUI Method:

1. Disk Management → Right-click partition → Properties
2. General tab shows:
- Used space
- Free space
- Capacity
- Pie chart visualization

Disk Cleanup (cleanmgr.exe):

1. Windows key → type "Disk Cleanup" → Select drive
2. Cleanup wizard calculates reclaimable space
3. Select categories:
- Temporary files
- Recycle Bin
- Thumbnails
- Windows Update cleanup
4. OK → Delete Files → Confirms and removes

Command-Line Tools:

# Get drive free space
Get-PSDrive -PSProvider FileSystem

# Output:
Name Used (GB) Free (GB) Provider
---- --------- --------- --------
C 120 350 FileSystem

# Disk Usage (DU) from Sysinternals
du -l 1 C:\Users # Show folder sizes, level 1 depth

Linux Disk Usage Commands

df (Disk Filesystem):

# Show free space on all filesystems
df -h

# Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 400G 120G 260G 32% /
/dev/sda1 511M 5.3M 506M 2% /boot/efi
tmpfs 7.9G 1.2M 7.9G 1% /run

# Show specific filesystem
df -h /home

# Show inode usage
df -i

du (Disk Usage):

# Disk usage of directory
du -h /home/user

# Summarize directory total only
du -sh /home/user

# Output: 15G /home/user

# Show top-level subdirectory sizes
du -h --max-depth=1 /home/user

# Find largest directories
du -h /home | sort -rh | head -20

Defragmentation and TRIM

Windows Defragmentation

Defragmentation rearranges file fragments scattered across disk into contiguous blocks, improving access speed on spinning hard drives.​​

When Needed:

  • HDDs (spinning disks): Benefits from regular defragmentation
  • SSDs: No benefit, potentially harmful—use TRIM instead

GUI Defragmentation:

1. This PC → Right-click drive → Properties
2. Tools tab → Optimize
3. Select drive → Analyze (check fragmentation %)
4. Optimize → Defragments drive
5. Change settings → Schedule automatic optimization

Command-Line:

# Analyze fragmentation
defrag C: /A

# Defragment drive
defrag C: /O

# Defragment all drives
defrag /C /O

Linux TRIM for SSDs

TRIM informs SSD controllers which data blocks are no longer in use, allowing the drive to erase and reuse cells efficiently.

Why TRIM Matters:

  • SSDs cannot overwrite data directly—must erase first
  • Without TRIM, SSD performance degrades over time
  • TRIM reclaims “deleted” blocks for reuse

Manual TRIM:

# TRIM all mounted filesystems supporting it
sudo fstrim -av

# Output:
/boot/efi: 500.5 MiB trimmed
/: 180.3 GiB trimmed

Automatic TRIM:

# Enable weekly TRIM timer (systemd)
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer

# Check status
sudo systemctl status fstrim.timer

fstab TRIM Option:

# Add 'discard' option to enable continuous TRIM (not recommended—weekly batch better)
UUID=12345-... / ext4 defaults,discard 0 1

⚠ Best Practice: Use weekly fstrim.timer instead of continuous discard mount option—batch TRIM has lower overhead.


Data Corruption and Recovery

Windows NTFS Self-Healing

Journaling:
NTFS logs metadata changes before committing them, enabling recovery if power failure or crash occurs mid-operation.​

Self-Healing:
Windows automatically repairs minor NTFS corruption in background without user intervention.​

Check Disk (chkdsk):

# Scan for errors (read-only, no fixes)
chkdsk C:

# Fix errors (requires exclusive access)
chkdsk C: /F

# If drive is in use:
# "Chkdsk cannot run because the volume is in use by another process.
# Would you like to schedule this volume to be checked the next time
# the system restarts? (Y/N)"
# Answer Y → Restart → chkdsk runs before Windows loads

# Scan, fix errors, recover readable data from bad sectors
chkdsk C: /F /R

# Check self-healing status
fsutil repair query C:

⚠ Warning: chkdsk /R takes hours on large drives—schedule during maintenance windows.

Linux fsck (File System Check)

fsck verifies and repairs Linux filesystems.​

Critical Rules:

  1. Never run fsck on mounted filesystems—causes severe corruption​
  2. Boot from live USB to check root filesystem
  3. Backup data before running repairs

Manual fsck:

# Unmount filesystem first
sudo umount /dev/sdb1

# Check and auto-repair errors
sudo fsck -y /dev/sdb1

# Output:
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
/dev/sdb1: clean, 11/640848 files, 83137/2560000 blocks

# Force check even if filesystem appears clean
sudo fsck -f /dev/sdb1

# Check specific filesystem type
sudo fsck.ext4 -y /dev/sdb1

Boot-Time fsck:

# Force fsck at next boot (root filesystem)
sudo touch /forcefsck
sudo reboot

# Or: Set maximum mount count before check
sudo tune2fs -c 30 /dev/sda2 # Check every 30 mounts

# Set maximum time between checks (180 days)
sudo tune2fs -i 180d /dev/sda2

# View filesystem check parameters
sudo tune2fs -l /dev/sda2 | grep -i "last checked\|mount count"

Automatic Boot-Time fsck:

# Edit /etc/default/rcS
sudo nano /etc/default/rcS

# Add line:
FSCKFIX=yes

# Enables automatic repair of errors found during boot

Key Takeaways

  • MBR supports 2 TB maximum disk size with 4 primary partitions and legacy BIOS, while GPT handles 9.4 ZB disks with 128 partitions and UEFI firmware—use GPT for new systems and disks >2 TB
  • NTFS provides journaling, compression, and permissions for Windows, ext4 offers robust journaling for Linux, and FAT32 delivers universal compatibility with 4 GB file size limitation​​
  • Windows assigns drive letters automatically while Linux requires explicit mount commands—use /etc/fstab for permanent mounts with UUID identifiers preventing device name changes​
  • Hard links point directly to file records (inodes) surviving renames, while symbolic links point to pathnames and break when targets move​
  • Defragmentation benefits spinning HDDs by consolidating fragmented files, but SSDs require TRIM instead to reclaim unused blocks—defragmenting SSDs causes unnecessary wear

Frequently Asked Questions

Q: Can I convert MBR to GPT without losing data?
A: Windows 10/11 includes mbr2gpt.exe that converts in-place without data loss: mbr2gpt /convert /disk:0 /allowFullOS. Backup first as precaution. Linux requires third-party tools like gdisk with more risk.

Q: Which file system should I use for an external drive shared between Windows and Linux?
A: Use NTFS with Linux ntfs-3g driver for best compatibility and no 4 GB file size limit. Install on Linux: sudo apt install ntfs-3g. Alternative: exFAT if both systems support it.​​

Q: How much swap space do I need on Linux?
A: Systems with <8 GB RAM: Use 1-2× RAM. Systems with ≥16 GB RAM: 4-8 GB swap suffices unless hibernation required (then match RAM size). Servers benefit from minimal swap (2-4 GB) to avoid thrashing.​

Q: Why does Windows show less space than disk capacity?
A: Reserved space includes: EFI system partition (100-500 MB), recovery partition (500 MB-10 GB), Windows system files, pagefile.sys, and hibernation file (hiberfil.sys = ~75% of RAM). Disable hibernation with powercfg /h off to reclaim space.

Q: Can I defragment an SSD?
A: No—defragmentation provides no benefit to SSDs and increases wear by writing unnecessarily. Use TRIM instead (fstrim on Linux, automatic in Windows 10+).

Q: What’s the difference between ‘quick format’ and ‘full format’?
A: Quick format removes file table pointers only (seconds), while full format writes zeros to entire disk and scans for bad sectors (hours). Use quick for new/reliable drives, full for used/suspicious drives.​


Next Steps

Disk management expertise develops through hands-on practice with non-critical systems—create test partitions, deliberately cause errors, then practice recovery techniques. Virtual machines provide safe environments for destructive operations without risking production data.

Hands-on practice labs:

  • Create dual-boot system with Windows and Linux partitions
  • Practice converting MBR to GPT on test disk
  • Configure Linux fstab with UUID-based mounts
  • Simulate disk corruption and practice chkdsk/fsck recovery
  • Set up swap partition and monitor swap usage under load
  • Create hard links and symbolic links, test behavior when targets move
  • Measure performance impact of different cluster sizes

Advanced topics to explore:

  • LVM (Logical Volume Manager) for dynamic disk management
  • RAID configurations (0, 1, 5, 10) for redundancy and performance
  • ZFS and Btrfs advanced filesystems with snapshotting
  • Disk encryption (BitLocker, LUKS) for data security
  • SAN and NAS storage architectures for enterprise

Facing disk management or data recovery challenges? Share your scenario in the comments or subscribe for weekly system administration tutorials covering storage, backup strategies, and disaster recovery planning.

Blog Category: System Administration / Storage Management

Arbaz
Arbaz

I’m a dedicated IT support and cloud engineering enthusiast with 3+ years of experience, passionate about solving problems, continuous learning, and creating innovative tech solutions.

Articles: 48

Leave a Reply

Your email address will not be published. Required fields are marked *