Course contentsShow
← Linux
Lesson 668 of 1,8197. Storage Management and Logical VolumesFree lesson

Logical volume mirroring

Provide hardware-agnostic redundancy within the operating system level.

In this lesson, you will learn how to achieve hardware-agnostic data redundancy by using logical volume mirroring to maintain identical copies of your data across two distinct physical storage devices.

The Concept of Mirroring

Up until now, we have used Logical Volume Manager (LVM) primarily to aggregate or extend storage. However, if a single physical disk fails, the data residing on that specific drive is lost. Logical volume mirroring solves this by instructing the kernel to write every data block to two or more separate Physical Volumes (PVs) simultaneously.

By using the operating system to manage this "RAID-1" style redundancy, you make your storage layer hardware-agnostic. It does not matter if your volumes are backed by two different physical SATA disks, two cloud-based virtual block devices, or a mix of both; LVM ensures that the data remains consistent and accessible as long as at least one mirror remains operational.

Implementation

To create a mirrored logical volume, you specify the mirror type when creating the volume. For example, if you have two PVs (/dev/sdb and /dev/sdc) added to a Volume Group named vg_data, you can create a mirrored logical volume like this:

lvcreate -L 10G -m1 -n mirror_vol vg_data

In this command:

  • -L 10G sets the size of the logical volume.
  • -m1 tells LVM to create one additional mirror (totaling two copies).
  • -n mirror_vol assigns the name to the volume.

When you write data to mirror_vol, LVM writes the data to both physical devices in the background. If one device suddenly goes offline, the kernel continues serving requests from the remaining healthy copy. Because this is implemented at the logical volume level, you do not need special hardware RAID controllers; the intelligence lives entirely within the Linux kernel’s device mapper, providing a consistent way to protect your data across any storage backend you choose to deploy.

Key Takeaway: Logical volume mirroring provides software-defined redundancy by maintaining synchronized data copies across separate physical devices, allowing your system to survive the failure of an individual storage drive.