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.

DirectoryPurpose
/Root
/homeUser data
/varLogs, dynamic data
/etcConfig files
/bin, /usr/binBinaries
/devDevices
/procProcess 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/data

Persistent 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:

RAIDUse Case
RAID 0Fast, no redundancy
RAID 1Mirroring
RAID 5Parity
RAID 10Best 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  # UUIDs

Advanced:

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/log cleanup

  • logrotate


🧠 12. Pro-Level Insights (This makes you stand out)

  • xfs cannot shrink, only grow

  • ext4 supports both grow + shrink

  • tmpfs uses RAM β†’ super fast

  • noatime mount option β†’ improves performance

  • UUID vs device names in /etc/fstab


🎯 How to Answer in Interview (Perfect Structure)

If asked:

πŸ‘‰ β€œExplain Linux filesystem”

Answer flow:

  1. Definition

  2. Storage stack (VFS)

  3. Types (ext4, xfs…)

  4. Mounting + FHS

  5. Inodes

  6. LVM

  7. Real-world usage