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.