đž 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.