๐พ Storage and LVM¶
Understanding how Linux stores, organizes and protects data.
Table of Contents¶
- Why Storage Matters
- Physical Disks
- Disk Layout
- Partitions
- Why Use Partitions?
- Filesystems
- Mount Points
- The Linux Filesystem Tree
- Common Mount Points
- What Happens During Boot?
- LVM Introduction
- Why LVM Exists
- Physical Volumes
- Volume Groups
- Logical Volumes
- LVM Workflow
- LVM Advantages
- Encryption
- Why Encrypt Data?
- LUKS Concepts
- Storage Commands
- 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:
- Detect storage
- Load filesystems
- Mount partitions
- 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.