Skip to content

💾 Storage and LVM

Understanding how Linux stores, organizes and protects data.


Table of Contents

  1. Why Storage Matters
  2. Physical Disks
  3. Disk Layout
  4. Partitions
  5. Why Use Partitions?
  6. Filesystems
  7. Mount Points
  8. The Linux Filesystem Tree
  9. Common Mount Points
  10. What Happens During Boot?
  11. LVM Introduction
  12. Why LVM Exists
  13. Physical Volumes
  14. Volume Groups
  15. Logical Volumes
  16. LVM Workflow
  17. LVM Advantages
  18. Encryption
  19. Why Encrypt Data?
  20. LUKS Concepts
  21. Storage Commands
  22. Mental Model

1ī¸âƒŖ Why Storage Matters

Every operating system needs a place to store:

  • files
  • applications
  • configuration
  • logs
  • user data

Without storage, all information would disappear when the computer shuts down.


2ī¸âƒŖ Physical Disks

Storage begins with a physical device.

Examples:

  • HDD (Hard Disk Drive)
  • SSD (Solid State Drive)
  • NVMe SSD

Linux sees these devices as storage resources that can be organized and divided.


3ī¸âƒŖ Disk Layout

Think of a disk as a completely empty piece of land.

Entire Disk
┌───────────────────┐
│                   │
│    Empty Space    │
│                   │
└───────────────────┘

Before it can be used efficiently, it is usually divided into sections.


4ī¸âƒŖ Partitions

A partition is a logical division of a disk.

Example:

Disk
├── Partition 1
├── Partition 2
└── Partition 3

Each partition behaves almost like an independent storage area.


5ī¸âƒŖ Why Use Partitions?

Partitions provide:

✅ Organization

✅ Isolation

✅ Easier management

✅ Better security


Example:

Partition 1 → System
Partition 2 → User Files
Partition 3 → Logs

If one partition fills up, the others remain unaffected.


6ī¸âƒŖ Filesystems

A filesystem defines how data is stored and organized.

Without a filesystem:

Disk = Raw Storage

Linux would not know how to manage files.


Common filesystems:

  • ext4
  • XFS
  • Btrfs

Think of a filesystem as:

The filing system of a library

It determines where everything is stored.


7ī¸âƒŖ Mount Points

Linux does not assign drive letters like Windows.

Instead, storage is attached to directories.

This process is called:

Mounting

Example:

Storage Device
      ↓
Mount Point
      ↓
/home

8ī¸âƒŖ The Linux Filesystem Tree

Linux has a single directory tree.

Everything starts at:

/

called:

Root Directory

Example:

/
├── home
├── var
├── boot
└── etc

Additional storage is attached somewhere inside this tree.


9ī¸âƒŖ Common Mount Points

/home

User files.


/var

Logs and changing data.


/boot

Boot-related files.


/

Root filesystem.


Example:

Disk A
   ↓
/

Disk B
   ↓
/home

🔟 What Happens During Boot?

When Linux starts:

  1. Detect storage
  2. Load filesystems
  3. Mount partitions
  4. Make data available

Only after mounting can files be accessed.


1ī¸âƒŖ1ī¸âƒŖ LVM Introduction

LVM means:

Logical Volume Manager

This is one of the most important Born2beroot concepts.

Many students struggle with it because it adds an extra layer between the disk and the filesystem.


1ī¸âƒŖ2ī¸âƒŖ Why LVM Exists

Traditional partitions are rigid.

Example:

Partition = 20 GB

If it becomes full, resizing may be difficult.


LVM introduces flexibility.

Instead of thinking about fixed partitions:

Think about storage pools

1ī¸âƒŖ3ī¸âƒŖ Physical Volumes

A Physical Volume (PV) is storage managed by LVM.

Example:

Disk
   ↓
Physical Volume

Think of a PV as raw storage that LVM can use.


1ī¸âƒŖ4ī¸âƒŖ Volume Groups

A Volume Group (VG) combines storage.

Example:

PV1 = 100 GB
PV2 = 100 GB

VG = 200 GB

Multiple disks can be combined into a single storage pool.


This is one of LVM's biggest advantages.


1ī¸âƒŖ5ī¸âƒŖ Logical Volumes

Logical Volumes (LVs) are created from the Volume Group.

Example:

Volume Group
     ↓
 ├── LV Home
 ├── LV Root
 └── LV Logs

To Linux, these behave similarly to partitions.


1ī¸âƒŖ6ī¸âƒŖ LVM Workflow

The easiest way to remember LVM:

Disk
  ↓
Physical Volume (PV)
  ↓
Volume Group (VG)
  ↓
Logical Volume (LV)
  ↓
Filesystem

Or visually:

Disk
 │
 â–ŧ
PV
 │
 â–ŧ
VG
 │
 â–ŧ
LV
 │
 â–ŧ
ext4

1ī¸âƒŖ7ī¸âƒŖ LVM Advantages

Benefits include:

✅ Easier resizing

✅ Flexible storage

✅ Better management

✅ Storage pooling


Example:

Traditional partition:

20 GB

Needs more space?

Often difficult.


LVM:

20 GB
      ↓
40 GB

Usually much easier to expand.


1ī¸âƒŖ8ī¸âƒŖ Encryption

Encryption protects stored data.

Without the correct key:

Data remains unreadable

Encryption converts:

Readable Data

into:

Protected Data

1ī¸âƒŖ9ī¸âƒŖ Why Encrypt Data?

Imagine someone steals a hard drive.

Without encryption:

Files may be readable

With encryption:

Files appear meaningless

without the correct credentials.


Benefits:

✅ Privacy

✅ Security

✅ Theft protection


2ī¸âƒŖ0ī¸âƒŖ LUKS Concepts

LUKS is commonly used for disk encryption on Linux.

Think of it as:

A lock protecting storage

Example:

Disk
   ↓
LUKS
   ↓
Filesystem

Before data can be accessed, the lock must be opened.


2ī¸âƒŖ1ī¸âƒŖ Storage Commands

Display disks:

lsblk

Display mounted filesystems:

df -h

Display filesystem usage:

du -sh folder

Display partition information:

fdisk -l

Display mount information:

mount

Display LVM information:

pvs
vgs
lvs

These commands help administrators understand storage layout.


2ī¸âƒŖ2ī¸âƒŖ Mental Model

Imagine a shopping center.

The disk is:

The entire building

Partitions are:

Individual stores

Filesystems are:

The organization system
inside each store

LVM is:

A manager capable of
expanding or shrinking stores
when needed

Encryption is:

A lock on the building

Final Mental Image

Disk
  ↓
Partition
  ↓
Filesystem
  ↓
Mount Point

Traditional storage.


Disk
  ↓
PV
  ↓
VG
  ↓
LV
  ↓
Filesystem

LVM storage.

This extra layer is what gives LVM its flexibility.