Courseiva
LPIC-2Chapter 6 of 15Objective 202.3

RAID and LVM Configuration

RAID and LVM are two technologies that let you pool multiple hard drives together to make them act like one huge, reliable, and flexible storage system. For the LPIC-2 exam, you need to know how to set up, manage, and troubleshoot these systems because real-world servers depend on them to prevent data loss and to allow storage to grow without downtime. Understanding this chapter means you can build storage that survives disk failures and expands without rebooting the server.

12 min read
Intermediate
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture RAID and LVM Configuration

The Office Filing Cabinet Expansion Analogy

First, your small business outgrows its single filing cabinet, so you must connect multiple cabinets together without losing any existing files. This leads you to a system where drawers and shelves can be combined, split, and moved around dynamically.

Imagine you run a small business and start with one four-drawer filing cabinet. As you hire more staff and get more clients, that single cabinet fills up. You could buy another identical cabinet and just stack papers in it, but that would mean some files are in the first cabinet and some in the second, with no easy way to find anything quickly. Instead, you install a clever rail system that lets you link multiple cabinets together into one giant, virtual filing system. You can now add new cabinets without moving any existing files. You can also take a drawer from one cabinet and slide it into a different cabinet while the office is still open, without anyone losing access to the documents inside. This rail system is your Logical Volume Manager (LVM) it allows you to combine physical cabinets (hard drives) into one big pool of storage (a volume group) and then carve out flexible drawers (logical volumes) that can grow or shrink as needed. Meanwhile, you also install a mirroring technique so that every important document is automatically copied into two different drawers in two separate cabinets. If one cabinet catches fire (a hard drive fails), you can still retrieve every file from the mirrored copy. This mirroring is RAID 1. Together, the rail system and mirroring give you flexibility and safety, just like LVM and RAID in a Linux server.

How It Actually Works

RAID stands for Redundant Array of Independent Disks. In plain English, it means taking several physical hard drives and making them work together as a single unit to improve performance, reliability, or both. LVM stands for Logical Volume Manager. It is a layer of software that sits between your operating system and your physical disks, allowing you to treat storage as flexible pools rather than fixed partitions.

To understand why both exist, think about the problems they solve. A single hard drive has a fixed size. If you run out of space, you cannot easily add more without reformatting and reinstalling everything. Also, a single hard drive is a single point of failure. If it breaks, you lose all data. RAID addresses the failure problem by copying data across multiple disks (mirroring) or by storing extra parity information that can rebuild lost data (striping with parity). LVM addresses the flexibility problem by letting you combine multiple disks into one volume group, then carving out logical volumes that can be resized, snapped, and moved.

Here are the most common RAID levels you must know for LPIC-2:

RAID 0 (striping): Data is split into blocks and written across two or more disks. This improves read and write speed because multiple disks work in parallel. However, it offers zero redundancy. If one disk fails, all data is lost. Use it only for non-critical data where speed is everything.

RAID 1 (mirroring): Data is written identically to two or more disks. Every piece of data exists on every disk in the array. This provides excellent fault tolerance. If one disk fails, the system keeps running with the other disk. The downside is that you lose half your raw capacity because every disk must hold the same data.

RAID 5 (striping with distributed parity): Data and parity information are striped across three or more disks. The parity is a mathematical checksum that can reconstruct data if one disk fails. You can lose any single disk and still access all data. Capacity is (N-1) disks worth, where N is the total number of disks.

RAID 6 (striping with double parity): Similar to RAID 5, but it uses two parity blocks distributed across all disks. This allows the array to survive two simultaneous disk failures. You need at least four disks. The write speed is slower than RAID 5 because of the extra parity calculation.

LVM operates in three layers. First, physical volumes (PVs) are the raw hard drives or partitions that you want to use, such as /dev/sdb and /dev/sdc. You initialise a disk as a physical volume using the command pvcreate. Second, you combine one or more physical volumes into a volume group (VG). This is a pool of storage space like a big bucket of free blocks. You create a volume group with vgcreate. Third, you carve logical volumes (LVs) out of the volume group. These logical volumes appear to the operating system as normal block devices, usually in /dev/mapper/ or /dev/VG-name/. You can format them with a filesystem (like ext4 or XFS) and mount them just like any partition. The magic of LVM is that you can extend a logical volume while it is still mounted and in use, without rebooting. You can also shrink some filesystems, though that is riskier and requires unmounting first.

Why would you use both RAID and LVM together? Imagine you have four 1TB hard drives. You could create a RAID 10 array (which is a stripe of mirrors) using hardware or software RAID. That gives you both speed and fault tolerance. Then, you put LVM on top of that RAID array so that you can create several logical volumes (for root, home, and data) and resize them as your needs change. This combination is very common in enterprise servers.

On Linux, you manage software RAID with the mdadm tool. mdadm stands for multiple disk administration. You can create, monitor, and repair RAID arrays with it. LVM is managed with a set of command-line tools: pvcreate, vgcreate, lvcreate, pvdisplay, vgdisplay, lvdisplay, and many more. Both technologies can be configured during system installation or later, but doing it later requires moving data, which is tricky. LPIC-2 expects you to know the commands and the sequence of steps for creating both RAID and LVM setups from scratch, as well as how to recover from a disk failure.

In summary, RAID gives you redundancy and performance. LVM gives you flexibility and online resizing. Together, they let you build storage systems that are resilient, adaptable, and manageable without taking servers offline.

Flowchart showing the step-by-step process of combining physical disks into a RAID array, then setting up LVM on top.

Walk-Through

1

Assess Hardware and Plan Layout

Check how many disks are available and their sizes. Decide which RAID level to use based on your need for speed, capacity, and fault tolerance. For example, if you have two empty 500GB disks and need to protect data, choose RAID 1. Plan whether to use LVM on top of the RAID array for future flexibility.

2

Partition the Disks

Use fdisk or parted to create partitions on each disk. For software RAID, set the partition type to 'Linux RAID' (hex code FD). This tells the kernel that these partitions will belong to an mdadm array. Each disk should have at least one partition of appropriate size.

3

Create the RAID Array with mdadm

Run sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1. This creates a mirrored array. Replace the level and devices as needed for RAID 0, 5, or 6. The array is now available as /dev/md0.

4

Initialise the Array as an LVM Physical Volume

Run sudo pvcreate /dev/md0. This adds metadata to the RAID array so LVM can manage it. You can verify with sudo pvdisplay. Multiple physical volumes can be added later to expand the volume group.

5

Create a Volume Group and Logical Volume

Create a volume group with sudo vgcreate vg_data /dev/md0. Then create a logical volume with sudo lvcreate -n lv_appdata -L 200G vg_data. The logical volume appears as /dev/vg_data/lv_appdata. Format it with a filesystem and mount it.

6

Configure Automatic Mounting and Monitoring

Add an entry to /etc/fstab for the logical volume. Set up a cron job or systemd timer to check /proc/mdstat daily and email the administrator if a disk fails. Regularly run sudo mdadm --detail /dev/md0 to verify the array health.

What This Looks Like on the Job

Imagine you are a junior system administrator at a mid-sized company that runs a web application for managing customer orders. The application stores all customer data, product catalogues, and transaction logs on a single Linux server. Your boss tells you that the server is running out of disk space, and the company cannot afford any downtime because orders come in 24/7. You also discover that the server has only one hard drive if that drive fails, the entire business stops. You need to implement RAID and LVM to solve both problems.

Your first step is to audit the existing hardware. The server has three empty drive bays. You install two new 500GB SATA hard drives (which we will call /dev/sdb and /dev/sdc) alongside the existing 500GB drive (called /dev/sda). You decide to use software RAID because the server does not have a hardware RAID controller. You plan to create a RAID 1 array (mirror) using the two new drives to protect the data, and then use LVM on top of the RAID array so that you can easily expand the storage in the future.

Here is the step-by-step walkthrough of what you actually do in the terminal:

Step 1: Partition the two new drives using fdisk or parted. You create a single Linux RAID partition on each (partition type FD for mdadm).

Step 2: Create the RAID 1 array with mdadm. The command is: sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1. This creates a mirrored array named /dev/md0.

Step 3: Initialise /dev/md0 as an LVM physical volume: sudo pvcreate /dev/md0.

Step 4: Create a volume group called vg_data: sudo vgcreate vg_data /dev/md0.

Step 5: Create a logical volume for your application data: sudo lvcreate -n lv_appdata -L 400G vg_data. This carves out a 400GB logical volume from the volume group.

Step 6: Format the logical volume: sudo mkfs.ext4 /dev/vg_data/lv_appdata.

Step 7: Mount it: sudo mount /dev/vg_data/lv_appdata /srv/appdata.

Now, you move the application data from the old drive to the new storage. You update /etc/fstab so that the logical volume mounts automatically on reboot. Six months later, the volume group is nearly full. Your boss buys two more 1TB drives. You add them to the server, partition them as RAID partitions, create another RAID 1 array, add that array as a physical volume to the existing volume group, and then extend the logical volume while the application is still running. This entire process happens with zero downtime. You also set up a cron job to email you the status of the RAID array every day, and you monitor the array with cat /proc/mdstat. When a disk eventually fails, you receive an email, you replace the faulty drive, partition it, and add it back to the RAID array with mdadm --manage /dev/md0 --add /dev/sdd1. The array rebuilds itself in the background while the server stays online. This is what an IT professional actually does with RAID and LVM on the job.

How LPIC-2 Actually Tests This

The LPIC-2 exam objective 202.3 focuses heavily on the practical commands for creating, managing, and troubleshooting RAID and LVM. You will not be asked to configure a hardware RAID controller because that varies by vendor. Instead, they test software RAID and LVM commands that work on any standard Linux distribution.

Here are the specific concepts LPIC-2 loves to test:

The mdadm command: Learn every subcommand, especially --create, --manage, --detail, --stop, and --assemble. You must know the syntax for creating RAID levels 0, 1, 5, 6, and 10. They often ask what flag to use to set the number of devices or the chunk size.

The LVM toolchain: You must know pvcreate, pvdisplay, pvremove, vgcreate, vgdisplay, vgextend, vgreduce, vgremove, lvcreate, lvdisplay, lvextend, lvreduce, lvremove. Pay special attention to lvextend and lvreduce because they frequently appear in scenario questions about resizing.

Filesystem resizing: Extending a logical volume is only half the job. You must also resize the filesystem inside it. For ext4, the command is resize2fs. For XFS, it is xfs_growfs. The exam often includes a trap where a candidate extends the LV but forgets to resize the filesystem, so the space is not available.

RAID superblock formats: You need to know about version 0.9, 1.0, 1.1, and 1.2 superblocks, and where they are stored on disk. They might ask which version is the default in modern mdadm.

Grub and RAID: If the /boot partition is on a RAID array, special considerations apply. The exam may test that GRUB can read from a RAID 1 array but not from RAID 5 or RAID 6 without additional configuration.

Failure simulation: Questions will ask what happens when a disk in a RAID 5 array fails. The correct answer pattern usually involves reassembling the array in degraded mode, then adding a new disk and letting it rebuild.

Common traps include:

Thinking that LVM snapshots are a backup. They are not. A snapshot is a point-in-time copy that shares blocks with the original. If the original changes too much, the snapshot fills up and becomes invalid. The exam will ask about snapshot space allocation.

Confusing the mount point with the logical volume. The mount point is just a directory. The logical volume is a block device.

Forgetting that a volume group cannot span multiple servers. LVM is a single-host technology. For shared storage across machines, you need a cluster-aware filesystem or network storage.

Mixing up pvscan, vgscan, and lvscan. Each scans a different layer (physical volumes, volume groups, logical volumes). They might ask which command to run after adding a new disk.

To memorise, focus on three cheat sheets:

RAID levels and their minimum number of disks, fault tolerance, and usable capacity.

The exact sequence of LVM commands: pvcreate, vgcreate, lvcreate, mkfs, mount.

The commands to extend an LV: lvextend -L +size /dev/vg/lv; then resize2fs /dev/vg/lv (for ext4).

Key Takeaways

RAID 1 mirrors data exactly across two disks, providing fault tolerance but sacrificing half your total raw capacity.

LVM separates physical storage from logical storage, allowing you to resize volumes without unmounting or rebooting the server.

The correct sequence for extending a logical volume is: lvextend, then resize2fs for ext4 or xfs_growfs for XFS.

A RAID 5 array must have at least three disks and can survive exactly one disk failure without data loss.

An LVM snapshot is a fixed-size, copy-on-write temporary copy, not a backup for long-term data retention.

The mdadm command is used to create, manage, and monitor software RAID arrays on Linux.

The /proc/mdstat file shows the current status of all active software RAID arrays, including rebuild progress.

When a disk in a RAID array fails, the array runs in degraded mode until you replace the disk and rebuild the array.

LVM volume groups can contain physical volumes from multiple disks, which can be of different sizes and types.

Hardware RAID and software RAID both achieve redundancy, but software RAID relies on the host CPU and is managed with mdadm.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

RAID 0 (Striping)

Data is split across disks for speed.

No fault tolerance; one failure destroys all data.

Usable capacity equals total disk size.

RAID 1 (Mirroring)

Data is duplicated identically on every disk.

Can survive one or more disk failures (depending on number of mirrors).

Usable capacity is half of total disk size (with two disks).

Software RAID (mdadm)

Uses the host CPU for parity calculations.

Managed entirely by the operating system.

No additional hardware cost.

Hardware RAID Controller

Has its own dedicated processor for parity calculations.

Appears to the OS as a single disk.

Requires a physical card and may have vendor-specific tools.

LVM Physical Volume (PV)

Represents a raw disk or partition.

Is the lowest layer in LVM.

Created with pvcreate.

LVM Logical Volume (LV)

Is a virtual block device carved from a volume group.

Is the layer you format and mount.

Created with lvcreate and resized with lvextend.

LVM Snapshot

Requires fixed allocated space; can overflow.

Is a point-in-time copy of block changes.

Recovers extremely quickly.

Traditional Backup (e.g., rsync)

Stores a separate full copy of data.

Can be incremental or full.

Allows storage on a separate medium or remote location.

Watch Out for These

Mistake

RAID is a backup solution.

Correct

RAID provides redundancy and fault tolerance, not backup. If you accidentally delete a file, RAID does not help. Backup copies data to a separate location.

People hear 'redundancy' and think it means data is safe from all loss. They do not distinguish between hardware failure and user error.

Mistake

LVM snapshots can grow automatically and can be used as a long-term backup.

Correct

LVM snapshots are fixed-size. If the original volume changes more than the snapshot size, the snapshot becomes invalid and unusable. They are for short-term consistent copies, not long-term backup.

The word 'snapshot' sounds like a mini-backup that can expand. Users do not realise that the snapshot is a copy-on-write block device with a hard limit.

Mistake

You can extend a logical volume without extending the underlying filesystem.

Correct

After extending the logical volume with lvextend, you must also run resize2fs (or xfs_growfs) to make the additional space available to the filesystem. The LV is just the block device; the filesystem sits on top of it.

Beginners think the LV is the filesystem itself. They run lvextend, then check df -h and see no new space, and assume the command failed.

Mistake

A RAID 0 array with two disks is twice as reliable as a single disk.

Correct

RAID 0 has zero fault tolerance. If either disk fails, all data is lost. It is actually less reliable than a single disk because there are more components that can fail.

The word 'array' implies safety through numbers. People do not calculate that the probability of failure doubles when you have two disks instead of one.

Mistake

You can add a disk to an existing RAID 5 array and instantly get the extra capacity without rebuilding.

Correct

Adding a disk to a RAID 5 array requires a reshape operation that rewrites data across all disks. The array remains online but performance is degraded until the reshape completes.

People confuse RAID with LVM. LVM can add a disk and immediately extend a volume, but RAID requires a time-consuming reshape process.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between RAID and LVM?

RAID combines multiple disks to improve performance or provide redundancy (mirroring, striping, parity). LVM is a layer that pools disks and allows flexible resizing of storage volumes. You often use both together: RAID for fault tolerance, LVM for easy management.

Can I add a new hard drive to an existing RAID 5 array without losing data?

Yes, you can add a new drive to a RAID 5 array using mdadm --add, but you must then reshape the array to use the new space. This process takes time and degrades performance, but the array stays online and data remains intact.

How do I extend a logical volume in LVM?

First, extend the logical volume with lvextend -L +10G /dev/vg_name/lv_name. Then, resize the filesystem inside it. For ext4, use resize2fs /dev/vg_name/lv_name. For XFS, use xfs_growfs /mount_point. Do not forget the second step.

What happens if one disk fails in a RAID 1 array?

The array continues to function in degraded mode using the remaining disk. You can still read and write data normally. Replace the failed disk, partition it, and add it back using mdadm --manage /dev/md0 --add /dev/newdisk. The array will rebuild automatically.

Why is my LVM snapshot filling up and becoming invalid?

An LVM snapshot is a fixed-size block device that stores changes to the original volume. If the volume changes by more than the snapshot's allocated space, the snapshot overflows and becomes corrupted. You must allocate enough space for the expected changes during the snapshot period.

What is the difference between pvdisplay, vgdisplay, and lvdisplay?

pvdisplay shows information about physical volumes (disks or partitions). vgdisplay shows details about volume groups (collections of physical volumes). lvdisplay shows information about logical volumes (the block devices you format and mount). Each command targets a different layer of LVM.

Terms Worth Knowing

Keep going

You've finished RAID and LVM Configuration. Continue through the LPIC-2 study guide to build a complete picture of the exam.

Done with this chapter?