1. What is Filesystem in Linux?
A filesystem defines how data is stored, organized, and accessed on storage devices.
π Think:
-
Disk = raw storage
-
Filesystem = structure + rules to store files
Examples:
-
ext4(most common in Linux) -
xfs(used in enterprise, high performance) -
btrfs(advanced features like snapshots) -
tmpfs(in-memory filesystem)
2. Linux Storage Stack (VERY IMPORTANT)
In interviews, always explain this layered architecture π
Application
β
Filesystem (ext4, xfs)
β
VFS (Virtual File System)
β
Block Layer
β
Device Drivers
β
Physical Disk (HDD/SSD/NVMe)
π₯ Key Points:
-
VFS (Virtual File System) β abstraction layer
β allows Linux to support multiple filesystems -
Apps donβt care if itβs ext4, xfs, NFS, etc.
π Interview line:
βLinux uses VFS to provide a unified interface across different filesystem types.β
ποΈ 3. Types of Filesystems (Important)
πΉ Local Filesystems
-
ext4β default, journaling, stable -
xfsβ high performance, large files -
btrfsβ snapshots, compression
πΉ Network Filesystems
-
NFSβ share storage across servers -
SMB/CIFSβ Windows-compatible sharing
πΉ Virtual / Special
-
procfsβ process info (/proc) -
sysfsβ kernel/device info (/sys) -
tmpfsβ RAM-based
π 4. Linux Directory Structure (FHS)
Very common question.
| Directory | Purpose |
|---|---|
/ | Root |
/home | User data |
/var | Logs, dynamic data |
/etc | Config files |
/bin, /usr/bin | Binaries |
/dev | Devices |
/proc | Process info |
π Interview tip:
βLinux follows FHS (Filesystem Hierarchy Standard) to maintain consistency.β
π½ 5. Storage Concepts (CORE DEVOPS PART)
πΉ Partitioning
Splitting disk into parts.
Commands:
fdisk
parted
lsblkπΉ Mounting
Linux doesnβt auto-use disks β you must mount.
mount /dev/sdb1 /mnt/dataPersistent mount:
/etc/fstabπ Critical interview point:
βEverything in Linux is mounted under root
/β unlike Windows drives.β
πΉ Inodes (VERY IMPORTANT)
Each file has an inode containing:
-
metadata
-
permissions
-
size
-
pointers to data blocks
π NOT filename (thatβs stored in directory)
Check:
ls -i
df -iπ Interview trap:
Disk can have free space but still fail if inodes are exhausted.
πΉ Journaling
Used in ext4, xfs
π Prevents corruption during crashes
β logs changes before writing
βοΈ 6. LVM (Logical Volume Manager) π₯π₯
VERY IMPORTANT for DevOps
Allows flexible storage management.
Structure:
Disk β PV β VG β LV β Filesystem
-
PV β Physical Volume
-
VG β Volume Group
-
LV β Logical Volume
Benefits:
-
Resize storage without downtime
-
Combine multiple disks
-
Snapshots
Commands:
pvcreate
vgcreate
lvcreate
lvextendπ Interview line:
βLVM abstracts physical storage and provides dynamic resizing and snapshots.β
β‘ 7. RAID (Redundant Array of Disks)
Used for:
-
performance
-
redundancy
Types:
| RAID | Use Case |
|---|---|
| RAID 0 | Fast, no redundancy |
| RAID 1 | Mirroring |
| RAID 5 | Parity |
| RAID 10 | Best combo |
π DevOps context:
- Used in servers, cloud disks internally
π 8. Disk Monitoring & Commands
Must-know commands:
df -h # disk usage
du -sh # folder size
lsblk # block devices
mount # mounted disks
blkid # UUIDsAdvanced:
iostat
iotopπ Interview tip:
Always mention monitoring + troubleshooting
π 9. Performance Concepts
-
SSD vs HDD vs NVMe
-
IOPS (Input/Output ops per second)
-
Throughput vs latency
π Example:
-
DB β needs high IOPS
-
Logs β sequential writes
βοΈ 10. Cloud + DevOps Context (IMPORTANT)
AWS Example:
-
EBS β block storage
-
S3 β object storage
-
EFS β network filesystem
Kubernetes:
-
Persistent Volumes (PV)
-
Persistent Volume Claims (PVC)
π Interview line:
βKubernetes abstracts storage using PV/PVC similar to how LVM abstracts disks.β
π₯ 11. Real Interview Scenarios
β Disk full but df shows space?
-
inode exhaustion
-
deleted file still open
β How to extend disk?
- add disk β LVM β resize β
resize2fs
β Logs filling disk?
-
/var/logcleanup -
logrotate
π§ 12. Pro-Level Insights (This makes you stand out)
-
xfscannot shrink, only grow -
ext4supports both grow + shrink -
tmpfsuses RAM β super fast -
noatimemount option β improves performance -
UUID vs device names in
/etc/fstab
π― How to Answer in Interview (Perfect Structure)
If asked:
π βExplain Linux filesystemβ
Answer flow:
-
Definition
-
Storage stack (VFS)
-
Types (ext4, xfsβ¦)
-
Mounting + FHS
-
Inodes
-
LVM
-
Real-world usage