Disk Management
1. What is Disk Management?
Disk management is the operating system's function of managing storage devices such as:
- HDD
- SSD
- USB drives
- Memory cards
- External drives
- Virtual disks
It includes:
initializing, partitioning, formatting, mounting, allocating space, managing free space, handling bad blocks, and maintaining disk information.
Simple view:
Application ↓ Operating System ↓ File System ↓ Disk Management ↓ Device Driver ↓ HDD / SSD
2. Why Is Disk Management Needed?
Suppose you install a new 1 TB SSD.
The OS needs to determine:
Is the disk detected? ↓ How is it partitioned? ↓ Which filesystem is used? ↓ Where should files be stored? ↓ Which blocks are free? ↓ How are bad blocks handled? ↓ How is the disk mounted/accessed?
Without disk management, the storage device would simply be raw storage with no convenient organization.
3. Basic Disk Structure
A traditional hard disk contains:
HDD | ┌────────┴────────┐ | | Platters Spindle | Tracks | Sectors
Important terms
Platter
A circular magnetic disk inside an HDD.
_____________ / \ | Platter | \_______________/
An HDD can have multiple platters.
4. Track
A track is a circular path on a magnetic platter.
Track ┌─────────┐ ┌─┼─────────┼─┐ │ │ │ │ │ │ │ │ └─┼─────────┼─┘ └─────────┘
Multiple tracks exist on a platter.
5. Sector
A sector is a subdivision of a track.
Conceptually:
Track ┌─────────────┐ │ \ | | | | / │ │ \| | | |/ │ │---\-----/---│ │ /| | |\ │ └─────────────┘ Sectors
Historically, 512 bytes was a common sector size; modern drives may use 4096-byte physical sectors.
6. Block
The filesystem normally works with logical blocks, which may consist of one or more sectors.
For example:
Sector: 512 bytes Filesystem block: 4096 bytes 4096 / 512 = 8 sectors
So one 4 KiB filesystem block can correspond to 8 × 512-byte sectors.
7. HDD vs SSD
This is important.
| Feature | HDD | SSD |
|---|---|---|
| Technology | Magnetic | Flash memory |
| Moving parts | Yes | No |
| Disk head | Yes | No |
| Seek time | Important | Very low |
| Mechanical wear | Yes | No mechanical wear |
| Noise | Can produce noise | Silent |
| Random access | Slower | Much faster |
| Disk scheduling importance | High | Different/usually lower |
The OS still manages both, but the underlying hardware behaves differently.
8. Disk Initialization
When a storage device is first prepared, several steps may be involved:
New Disk ↓ Initialize ↓ Partition ↓ Format ↓ Mount ↓ Use
These operations are different.
9. Partitioning
A partition is a logical division of a physical storage device.
For example:
1 TB SSD ┌───────────────────────────────────┐ │ Partition 1 │ Partition 2 │ ... │ │ 500 GB │ 400 GB │ 100GB│ └───────────────────────────────────┘
The OS can treat partitions as separate logical storage areas.
10. Why Partition a Disk?
Partitioning can be used to:
- separate operating systems
- separate system and personal data
- organize storage
- use different filesystems
- create recovery areas
- support boot configurations
Example:
SSD │ ├── EFI System Partition ├── Windows ├── Linux └── Data
11. MBR and GPT
Two important partitioning schemes are:
MBR GPT
MBR
Master Boot Record
Older partitioning scheme.
Traditionally supports:
- up to 4 primary partitions
- disks up to about 2 TB with common 512-byte logical sectors
Extended/logical partitions can work around the four-primary-partition limitation.
12. GPT
GUID Partition Table
Modern partitioning scheme commonly used with UEFI systems.
Advantages include:
- supports many partitions
- supports very large disks
- stores partition information redundantly
- includes integrity checking
- works well with modern UEFI boot systems
Conceptually:
GPT Disk ┌────────┬───────────────┬───────────────┬─────────────┐ │ Header │ Partition │ Data │ Backup │ │ │ Entries │ │ structures │ └────────┴───────────────┴───────────────┴─────────────┘
13. Partition vs Filesystem
These are not the same thing.
Partition
Defines a region of the storage device.
Filesystem
Organizes files inside that region.
Example:
Physical SSD ↓ Partition ↓ ext4 filesystem ↓ Directories ↓ Files
Another example:
SSD ↓ Partition ↓ NTFS ↓ Windows files
14. Formatting
Formatting prepares a partition/storage area with a filesystem structure.
For example:
Partition ↓ Format as ↓ ext4
or:
Partition ↓ Format as ↓ NTFS
or:
Partition ↓ Format as ↓ FAT32
15. Low-Level vs High-Level Formatting
Low-level formatting
Historically involved preparing physical sectors/tracks.
Modern drives are generally factory low-level formatted, so users normally don't perform this operation.
High-level formatting
Creates filesystem structures such as:
Superblock / metadata Free-space structures Directories Allocation structures
This is what users normally mean by formatting a partition.
16. Mounting
A filesystem must be made available to the OS before applications can normally access its files through the filesystem namespace.
This process is called mounting.
Linux example:
/dev/sdb1 ↓ mount ↓ /mnt/data
Then:
/mnt/data/file.txt
can access files on that filesystem.
17. Linux Mount Structure
Linux has a single hierarchical filesystem tree.
Example:
/ ├── home ├── etc ├── var ├── usr ├── boot └── mnt
A separate filesystem can be mounted somewhere in this tree.
For example:
/dev/sdb1 ↓ /data
Then:
/data
represents the mounted filesystem.
18. Windows Drive Letters
Windows commonly exposes volumes using drive letters.
Example:
C:\ D:\ E:\
For example:
C:\Windows D:\Movies E:\USB
This differs from Linux's single-tree namespace.
19. Free-Space Management
The OS/filesystem needs to know which disk blocks are available.
Common techniques include:
1. Bitmap
Block: 0 1 2 3 4 5 6 7 Status: 1 1 0 1 0 0 1 0
For example:
1 = allocated 0 = free
So free blocks are:
2, 4, 5, 7
2. Free List
A linked list of free blocks:
Free Block ↓ 10 → 25 → 31 → 42 → NULL
20. Bad Blocks
A bad block is a storage block/sector that cannot reliably store or retrieve data.
Example:
Disk: [Good][Good][BAD][Good][Good]
Bad blocks can result from:
- physical damage
- wear
- manufacturing defects
- storage degradation
21. Handling Bad Blocks
The storage system may detect problematic sectors and prevent normal use of them.
Modern drives can often use spare physical sectors through internal remapping.
Conceptually:
Bad sector ↓ Detected ↓ Marked/remapped ↓ Spare sector used
The OS/filesystem may also maintain information about unusable blocks.
22. Disk Formatting and Bad Blocks
During certain formatting or disk-check operations, bad areas may be identified.
For example:
Disk ↓ Check sectors ↓ Identify bad areas ↓ Avoid/remap them
Modern SSDs and HDDs handle much of the physical defect management internally.
23. Swap Space
Swap space is disk/SSD space used to support virtual memory when pages cannot remain in RAM.
Example:
RAM ┌──────────────┐ │ Page A │ │ Page B │ │ Page C │ └──────────────┘ ↓ memory pressure Swap ┌──────────────┐ │ Page D │ │ Page E │ └──────────────┘
When needed, pages can be moved between RAM and swap.
Important:
Swap is not a replacement for RAM. Storage is much slower than RAM.
24. Swap Partition vs Swap File
Linux can use:
Swap partition
A dedicated partition:
/dev/sda3 ↓ Swap
Swap file
A regular file configured for swapping:
/swapfile
Modern Linux systems commonly support both.
25. Disk Scheduling
When multiple disk I/O requests are waiting, the OS may decide the order in which requests are serviced.
For HDDs, this can reduce disk-head movement.
Example:
Current head = 50 Requests: 10, 20, 55, 80, 90
The OS can choose an efficient order rather than simply processing requests randomly.
Common algorithms include:
FCFS SSTF SCAN C-SCAN LOOK C-LOOK
This is the next topic after disk management, so we'll study it separately in detail.
26. Disk Scheduling vs File Allocation
Don't confuse these.
File allocation
Answers:
Which blocks belong to this file?
Example:
File A → 10, 11, 12, 13
Disk scheduling
Answers:
Which pending disk I/O request should be serviced first?
Example:
Requests: 10, 20, 50, 80 Which one should the disk service next?
27. Storage Management
The OS also manages storage-related resources such as:
Storage │ ├── Partitions ├── Filesystems ├── Free space ├── Blocks ├── Mount points ├── Swap ├── Bad blocks └── I/O requests
The goal is:
- efficient storage use
- reliability
- performance
- data organization
- protection
28. Disk Caching
The OS can keep frequently used disk data in RAM.
Example:
Application ↓ RAM Cache ↓ Disk
If the required data is already cached:
Application ↓ RAM
No immediate disk access is necessary.
This can significantly improve performance.
29. Buffering
A buffer temporarily holds data during I/O.
Example:
Application ↓ Buffer ↓ Storage Device
Buffers help deal with differences in speed and transfer size between components.
30. RAID
RAID = Redundant Array of Independent Disks
RAID combines multiple physical drives to provide combinations of:
- performance
- redundancy
- availability
Common levels:
RAID 0 RAID 1 RAID 5 RAID 6 RAID 10
RAID 0 — Striping
Data is distributed across drives.
Disk 1 Disk 2 A1 A2 A3 A4 A5 A6
Advantages:
- high performance
- full combined capacity
Disadvantage:
- no redundancy
If one drive fails, the array's data can be lost.
31. RAID 1 — Mirroring
Data is duplicated.
Disk 1 Disk 2 A A B B C C
If Disk 1 fails:
Disk 2 still has the data
Advantage:
- excellent redundancy
Disadvantage:
- usable capacity is approximately half of raw capacity for a two-drive mirror.
32. RAID 5
Uses:
Striping + Distributed Parity
Conceptually:
Disk 1 Disk 2 Disk 3 A1 A2 P B1 P B2 P C1 C2
Can generally tolerate one drive failure.
Requires at least 3 drives.
33. RAID 6
Similar to RAID 5 but uses additional parity.
Generally:
Can tolerate two drive failures.
Requires at least 4 drives.
34. RAID 10
RAID 10 combines:
RAID 1 + RAID 0
Conceptually:
RAID 10 | ┌─────┴─────┐ Mirror Mirror / \ / \ Disk1 Disk2 Disk3 Disk4
It provides:
- good performance
- redundancy
But requires more drives and usable capacity is lower than RAID 0.
35. RAID Comparison
| RAID | Technique | Fault Tolerance | Main Advantage |
|---|---|---|---|
| RAID 0 | Striping | None | Performance |
| RAID 1 | Mirroring | 1 drive in each mirror pair | Reliability |
| RAID 5 | Striping + parity | 1 drive | Balance |
| RAID 6 | Striping + dual parity | 2 drives | Higher protection |
| RAID 10 | Mirroring + striping | Depends on failures | Performance + redundancy |
Important: RAID is not a backup.
If you accidentally delete a file, RAID normally replicates that deletion too.
36. Disk Management in Linux
Useful commands include:
lsblk
Shows block devices.
df -h
Shows filesystem disk usage.
du -sh directory
Shows space used by a directory.
mount
Shows mounted filesystems.
findmnt
Shows filesystem mount information.
blkid
Shows filesystem/device identifiers.
sudo fdisk -l
Shows partition information.
For GPT/modern partitioning:
sudo parted -l
37. Example Linux Disk Structure
Suppose:
lsblk
shows conceptually:
sda ├── sda1 ├── sda2 └── sda3
Meaning:
/dev/sda │ ├── /dev/sda1 ├── /dev/sda2 └── /dev/sda3
/dev/sda is the disk and the numbered entries are partitions.
38. Windows Disk Management
Windows provides a graphical Disk Management utility.
It can be used for tasks such as:
- viewing disks
- creating partitions
- deleting partitions
- formatting volumes
- assigning drive letters
- shrinking volumes
- extending volumes
- initializing disks
Typical structure:
Disk 0 ├── EFI/System ├── C: ├── Recovery └── Other volume
39. Disk Management Lifecycle
A useful way to remember the complete process:
Physical Disk ↓ Initialization ↓ Partitioning ↓ Formatting ↓ Mounting ↓ File Allocation ↓ File Operations ↓ Free-Space Management ↓ Disk Maintenance
40. Disk Management vs File System
| Disk Management | File System |
|---|---|
| Manages storage devices | Organizes files |
| Handles partitions | Handles directories/files |
| Mounting | File allocation |
| Free-space coordination | File metadata |
| Bad-block considerations | Permissions |
| Swap | File operations |
| Storage configuration | File organization |
They work together.
Disk Management ↓ Storage ↓ Filesystem ↓ Files & Directories
41. Complete Example
Suppose you connect a new 1 TB SSD.
Step 1 — OS detects it
SSD detected
Step 2 — Partition it
1 TB ├── 500 GB └── 500 GB
Step 3 — Create filesystems
500 GB → NTFS 500 GB → ext4
Step 4 — Mount/access them
Linux might have:
/dev/nvme0n1p1 → / /dev/nvme0n1p2 → /data
Step 5 — Create files
/data ├── videos ├── documents └── projects
Step 6 — Filesystem allocates blocks
project.zip ↓ blocks 100–150
Step 7 — OS manages I/O
Application ↓ Filesystem ↓ Block layer ↓ Driver ↓ SSD
🧠 Exam Revision
Definition
Disk management is an operating-system function responsible for managing storage devices, partitions, filesystems, free space, mounting, bad blocks, swap space, and disk I/O resources.
Important concepts
Disk Management │ ├── Disk structure │ ├── Platters │ ├── Tracks │ ├── Sectors │ └── Blocks │ ├── Partitioning │ ├── MBR │ └── GPT │ ├── Formatting │ ├── Mounting │ ├── Free-space management │ ├── Bitmap │ └── Free list │ ├── Bad-block management │ ├── Swap space │ ├── Disk caching/buffering │ ├── RAID │ └── Disk scheduling
Most important distinctions
Partition ≠ filesystem
Disk ↓ Partition ↓ Filesystem ↓ Files
File allocation ≠ disk scheduling
File allocation → Where are a file's blocks? Disk scheduling → Which I/O request should be serviced first?
🧠 Memory trick
Disk Management = Initialize → Partition → Format → Mount → Allocate → Manage → Maintain