Skip to main content

Command Palette

Search for a command to run...

Complete Beginner-to-Pro Guide: LVM Linear vs. LVM Striping

Published
6 min read
Complete Beginner-to-Pro Guide: LVM Linear vs. LVM Striping

This guide will help you understand, configure, and benchmark LVM Linear and LVM Striped volumes using four 1 GB disks (/dev/sda, /dev/sdb, /dev/sdc, /dev/sdd).

We will:
✅ Understand LVM Linear vs. LVM Striping (definitions, diagrams, analogies).
✅ Prepare four disks and create partitions.
✅ Create PVs, a VG, and both types of LVs.
✅ Benchmark them with fio (Sequential Write, Sequential Read, Random Mixed).
✅ Compare results and explain when to use each.

⚠️ Warning: This will erase /dev/sda–/dev/sdd. Only test on lab disks — never your OS disk.


Step 1. Understanding LVM Types

1. Striped LVM

  • Definition: Data is split into chunks (stripes) and written to multiple disks in parallel (like RAID-0).

  • Analogy: Four friends carrying bricks at the same time.

  • Benefit: Much higher throughput.

  • Risk: No redundancy — if one disk fails, all data is lost.

Diagram (4 disks, 64 KB stripes):

File Data →

+------+------+------+------+------+------+------+------+------+
|64KB  |64KB  |64KB  |64KB  |64KB  |64KB  |64KB  |64KB  | ...
+------+------+------+------+------+------+------+------+------+

Disk Layout:

/dev/sda1: [64KB]     [64KB]     [64KB] ...
/dev/sdb1:     [64KB]     [64KB]     [64KB] ...
/dev/sdc1:         [64KB]     [64KB]     [64KB] ...
/dev/sdd1:             [64KB]     [64KB]     [64KB] ...

2. Linear LVM

  • Definition: Data is written sequentially — one disk fills up before the next is used.

  • Analogy: Filling one bookshelf completely before moving to the next.

  • Benefit: Simple capacity aggregation.

  • Drawback: No performance gain; behaves like a single disk.

Diagram (2 disks, 1 GB each):

File Data →

+---------+---------+
| 1 GB    | 1 GB    |
+---------+---------+

Disk Layout:

/dev/sda1: [1 GB full]
/dev/sdb1: [next 1 GB]

Step 2. Prepare Disks with fdisk

Now we need to attach four disks and each of 1GB /dev/sda, /dev/sdb, /dev/sdc, /dev/sdd

We’ll create one full-size partition per disk. Example for /dev/sda:

sudo fdisk /dev/sda

Inside fdisk, type:

g   # new GPT table
n   # new partition
<enter> <enter> <enter>  # accept defaults
t   # change type
8e  # Linux LVM by pressing 8e it will change type to lvm
w   # write changes

👉 Why type 8e?
This ID marks the partition as Linux LVM, making its purpose clear to the system.

Now run command to update partition table:

partprobe /dev/sda

Repeat for /dev/sdb, /dev/sdc, /dev/sdd.
Or after creating all partitions you can run this command to update partiton table at once.

partprobe /dev/sd{a..d}
#OR
partprobe /dev/sd[abcd]

Verify:

lsblk
#OR
lsblk -o NAME,SIZE,TYPE /dev/sd{a..d}

Step 3. Create LVM Components

Physical Volumes (PVs)

sudo pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
sudo pvs

Volume Group (VG)

sudo vgcreate vg_lab /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

sudo vgs -o +devices

Striped Logical Volume (LV)

sudo lvcreate -n lv_striped -L 2G -i4 -I64 vg_lab
sudo mkfs.ext4 /dev/vg_lab/lv_striped #OR you can use any other filesystem like xfs etc
sudo mkdir -p /mnt/lv_striped 
sudo mount /dev/vg_lab/lv_striped /mnt/lv_striped
sudo lvs -o+devices,stripes,stripesize
df -hT /mnt/lv_striped
  • -i4 → 4 stripes (use 4 disks)

  • -I64 → stripe size 64 KB

  • -L 20G → LV size

  • -n striped_lv → LV name

  • vg_lab → VG name

1️⃣ Should the number of stripes (-i) = number of PVs?

Yes ✅

  • The -i option in lvcreate = number of physical volumes to stripe across.

  • If you have 2 PVs, then -i2 makes sense.

  • If you have 4 PVs, you can do -i4.

  • If you set -i bigger than available PVs in the VG, the command will fail.

👉 Rule: Number of stripes ≤ number of PVs in the VG.


2️⃣ What is stripe size (-I)?

  • Stripe size = size of each chunk written to one PV before moving to the next PV.

  • In my example I used -I64 (64 KB), but it can be any power of 2 from 4 KB up to 1 MB (depends on your LVM version/kernel).

How to choose stripe size:

  • Small stripe size (e.g., 64 KB)

    • Better for workloads with lots of small random reads/writes (databases, metadata-heavy apps).
  • Large stripe size (e.g., 256 KB, 512 KB, 1 MB)

    • Better for large sequential workloads (VM disk images, video editing, backups).

👉 There is no one-size-fits-all — you tune based on workload.


Linear Logical Volume (LV)

sudo lvcreate -n lv_linear -L 1.8G vg_lab
sudo mkfs.ext4 /dev/vg_lab/lv_linear #OR you can use any other filesystem like xfs etc
sudo mkdir -p /mnt/lv_linear
sudo mount /dev/vg_lab/lv_linear /mnt/lv_linear
df -hT /mnt/lv_linear

Step 4. Benchmarking with fio

👉 Always run fio against files inside mounted LVs, not raw devices, to avoid No space left on device errors.

Install fio:

sudo apt install fio -y    # Ubuntu/Debian
sudo dnf install fio -y    # RHEL/CentOS

🔹 Striped LV Tests

1️⃣ Sequential Write

fio --name=seqw_striped --filename=/mnt/lv_striped/testfile \
  --size=900M --direct=1 --rw=write --bs=1M --runtime=30 --group_reporting

Output is here:

2️⃣ Sequential Read

fio --name=seqr_striped --filename=/mnt/lv_striped/testfile \
  --size=900M --direct=1 --rw=read --bs=1M --runtime=30 --group_reporting

Output is here:

3️⃣ Random 70/30 Read/Write

fio --name=rand_striped --filename=/mnt/lv_striped/testfile \
  --size=900M --direct=1 --rw=randrw --rwmixread=70 \
  --bs=4k --iodepth=16 --numjobs=4 --runtime=30 --group_reporting

Output is here:


🔹 Linear LV Tests

1️⃣ Sequential Write

fio --name=seqw_linear --filename=/mnt/lv_linear/testfile \
  --size=900M --direct=1 --rw=write --bs=1M --runtime=30 --group_reporting

Output is here:

2️⃣ Sequential Read

fio --name=seqr_linear --filename=/mnt/lv_linear/testfile \
  --size=900M --direct=1 --rw=read --bs=1M --runtime=30 --group_reporting

Output is here:

3️⃣ Random 70/30 Read/Write

fio --name=rand_linear --filename=/mnt/lv_linear/testfile \
  --size=900M --direct=1 --rw=randrw --rwmixread=70 \
  --bs=4k --iodepth=16 --numjobs=4 --runtime=30 --group_reporting

Output is here:


Step 5. Results & Comparison

Test TypeLinear LV (Single-Disk Behavior)Striped LV (4-Disks in Parallel)
Sequential WriteSimilar to 1 disk (~100 MB/s)~4× higher throughput (~400 MB/s)
Sequential ReadSimilar to 1 disk (~100 MB/s)~4× higher throughput (~400 MB/s)
Random Read/WriteLimited IOPSHigher IOPS due to parallelism

Summary:

  • Linear = Simple capacity expansion. Best if you just need bigger storage.

  • Striped = High performance (like RAID-0). Great for databases, VMs, video editing. But ⚠️ one disk failure = total data loss.


Step 6. Cleanup

sudo umount /mnt/lv_linear /mnt/lv_striped
sudo lvremove -y /dev/vg_lab/lv_linear
sudo lvremove -y /dev/vg_lab/lv_striped
sudo vgremove -y vg_lab
sudo pvremove -y /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

Or further you can remove all partition using fdisk.


🎉 Congratulations! You’ve built, benchmarked, and compared LVM Linear vs. Striped volumes — and now know when to use each.

More from this blog

Usama Aijaz's blog

22 posts