Disk and Storage Management in Linux
Disk and storage management in Linux refers to how the operating system detects, organizes, uses, and maintains storage devices such as hard disks, SSDs, USB drives, and virtual disks. It is one of the most important system administration skills because everything in Linux files, programs, users, logs depends on proper storage handling.
Linux Disk and Storage Management, Disk and Partition, Disk Management Commands in Linux, Partitioning Tools, File System Creation, Swap Space, Logical Volume Manager (LVM), Real-World Example, Linux Disk Management Commands – Cheat Sheet, and Interview Questions were all covered in this blog.
Disk and Partition
What is a Disk?
A disk is a type of storage device, either virtual or actual.
For instance:
- Hard Disk Drive (HDD)
- Solid State Drive (SSD)
- USB drive
- Virtual disk (in VMware/VirtualBox)
In Linux, disks appear as:
/dev/sda,/dev/sdb,/dev/nvme0n1
What is a Partition?
A partition is a logical division of a disk.
For instance, a 1TB drive can be divided into:
- 300GB for OS
- 500GB for data
- 200GB for backup
Linux names partitions like:
/dev/sda2/dev/sda1
Also read about Linux File System Structure Explained: Root And Directories
Disk management commands in linux

df (Disk Free)
Shows how much space is used and available.
bash
df -h
Output shows:
- Total size
- Used space
- Available space
- Mount points
du (Disk Usage)
Shows size of files and folders.
bash
du -sh /home
Tells how much space /home uses.
lsblk (List Block Devices)
Shows all disks and partitions in tree format.
bash
lsblk
Very useful to visualize storage layout.
mount
Attaches a disk to a directory.
bash
mount /dev/sdb1 /mnt
Now /mnt shows the content of /dev/sdb1.
umount
Detaches a disk.
bash
umount /mnt
Also read about Process Management In Linux Commands With Examples
Partitioning Tools
fdisk (Classic Tool)
Used for creating and deleting partitions.
bash
fdisk /dev/sda
Inside fdisk:
n→ new partitiond→ deletew→ write changes
parted (Modern Tool)
Supports large disks and GPT.
bash
parted /dev/sda
More powerful than fdisk.
File System Creation
After partitioning, you must format the partition.
mkfs (Make File System)
bash
mkfs.ext4 /dev/sda1
Creates EXT4 filesystem.
Common file systems:
Swap Space
Swap is virtual memory on disk used when RAM is full.
Why swap exists?
- Prevent system crash
- Helps low-memory systems
- Used for hibernation
Create swap file:
bash
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Check swap:
bash
free -h
Logical Volume Manager (LVM)
Flexible disk management is made possible with LVM.
You could:
- Resize partitions live
- Combine multiple disks
- Create snapshots
- Add storage without reinstalling OS
LVM Structure
mathematica
Disk → PV → VG → LV → File System
Physical Volume (PV)
Actual disk or partition.
Create:
bash
pvcreate /dev/sdb
Volume Group (VG)
Group of PVs.
Create:
bash
vgcreate myvg /dev/sdb
Logical Volume (LV)
Virtual partition inside VG.
Create:
bash
lvcreate -L 10G -n mylv myvg
Format and Mount LVM
bash
mkfs.ext4 /dev/myvg/mylv
mount /dev/myvg/mylv /data
Also read about Kill Process Linux: Commands, Signals And Real Examples
Real-World Example
You add a new 500GB disk.
Steps:
- Detect disk
bash
lsblk
- Create PV
bash
pvcreate /dev/sdb
- Add to VG
bash
vgextend myvg /dev/sdb
- Extend LV
bash
lvextend -L +500G /dev/myvg/mylv
- Resize filesystem
bash
resize2fs /dev/myvg/mylv
No reboot needed.
Linux Disk Management Commands – Cheat Sheet
These commands help you inspect disks, manage partitions, format storage, mount devices, and monitor disk usage.
Disk Information Commands
These commands show available disks and their details.
| Command | Purpose |
|---|---|
lsblk | List all disks and partitions |
lsblk -f | Show file systems and UUIDs |
blkid | Display disk UUID and type |
fdisk -l | Show partition tables |
mount | Show mounted devices |
findmnt | Show mount points |
Example:
bash
lsblk
Disk Usage Commands
These commands show how much space is used.
| Command | Purpose |
|---|---|
df -h | Disk free space (human readable) |
du -sh folder | Size of a directory |
du -ah | All files and folders |
ncdu | Interactive disk usage viewer |
Example:
bash
df -h
Partition Management Commands
Used to create, delete, or modify partitions.
| Command | Purpose |
|---|---|
fdisk /dev/sda | Partition disk (MBR) |
cfdisk /dev/sda | GUI partition tool |
parted /dev/sda | GPT partitions |
sfdisk | Script-based partitioning |
Example:
bash
fdisk /dev/sdb
File System Commands
Used to format and repair disks.
| Command | Purpose |
|---|---|
mkfs.ext4 /dev/sda1 | Create ext4 file system |
mkfs.xfs /dev/sda1 | Create XFS |
fsck /dev/sda1 | Check file system |
tune2fs | Modify ext file systems |
Example:
bash
mkfs.ext4 /dev/sdb1
Also read about How To Install Garuda Linux On Virtualbox Easy Setup Guide
Mounting & Unmounting
Attach or detach disks.
| Command | Purpose |
|---|---|
mount /dev/sdb1 /mnt | Mount disk |
umount /mnt | Unmount |
mount -o ro | Read-only mount |
mount -a | Mount all from fstab |
Example:
bash
mount /dev/sdb1 /mnt
Swap Space Management
Used for virtual memory.
| Command | Purpose |
|---|---|
swapon -s | Show swap |
mkswap /dev/sda2 | Create swap |
swapon /dev/sda2 | Enable swap |
swapoff /dev/sda2 | Disable swap |
Example:
bash
swapon -s
LVM (Logical Volume Manager)
Advanced dynamic storage.
| Command | Purpose |
|---|---|
pvcreate | Create physical volume |
vgcreate | Create volume group |
lvcreate | Create logical volume |
lvextend | Expand volume |
lvdisplay | Show volumes |
Example:
bash
lvcreate -L 10G -n mylv myvg
Disk Performance & Health
Check disk health and speed.
| Command | Purpose |
|---|---|
iostat | Disk I/O stats |
iotop | Disk usage by process |
smartctl | Disk health |
badblocks | Scan bad sectors |
hdparm | Disk speed |
Example:
bash
smartctl -a /dev/sda
Also read about Explain File Permissions In Linux & Ownership With Examples
Backup & Cloning
Copy disks and data.
| Command | Purpose |
|---|---|
rsync | Backup files |
dd | Clone disk |
tar | Archive |
gzip | Compress |
borg | Backup tool |
Example:
bash
dd if=/dev/sda of=/dev/sdb
Emergency Recovery
Used when system fails.
| Command | Purpose |
|---|---|
mount -o remount,rw / | Fix read-only root |
fsck -y | Auto repair |
initramfs | Boot recovery |
chroot | Repair broken system |
Interview Questions
“How do you check disk usage in Linux?”
Answer:
bash
df -h
“How to find disk size?”
bash
lsblk
“How to mount a USB drive?”
bash
mount /dev/sdb1 /mnt
Interview Key Points
| Concept | Meaning |
|---|---|
| df | Shows free disk |
| du | Shows folder size |
| lsblk | Shows disk layout |
| mount | Attach disk |
| umount | Detach disk |
| fdisk | Partition tool |
| mkfs | Format disk |
| swap | Virtual RAM |
| PV | Physical disk |
| VG | Pool of disks |
| LV | Virtual partition |
Summary
Linux disk management commands allow you to view, create, format, mount, monitor, repair, and optimize storage devices, making Linux one of the most powerful operating systems for storage control.
Also read about Basic Linux Commands For Beginners With Easy Examples
