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

LVM mirror log management

Optimize metadata synchronization for mirrored logical volumes.

In this lesson, you will learn how to optimize metadata synchronization for mirrored logical volumes by managing the LVM mirror log.

When you create a mirrored logical volume (LV), LVM must keep track of which regions are synchronized between the two physical disks. If the system crashes, LVM needs to know which parts of the mirror are inconsistent so it can perform a resync upon reboot. This "to-do list" is handled by the mirror log.

Types of Mirror Logs

By default, LVM stores the log on a physical device, just like your data. However, how you store this log impacts performance:

  1. Disk-based log: This is the default. The log is written to a separate small area on one of your physical disks. It survives reboots, which is safe, but it requires an extra disk I/O operation every time a write occurs.
  2. Memory-based log (core): You can instruct LVM to keep the log in RAM by using the --mirrorlog core flag. This is lightning fast because it avoids disk writes for metadata. However, because RAM is volatile, LVM will not know the state of the mirror after a crash, forcing a "full resync" of the entire volume when the system comes back up.

Implementing the Log Type

When creating a mirrored volume, you specify the log type to suit your availability needs:

# Create a mirror with a memory-based log for speed
lvcreate -m 1 -L 10G -n my_fast_mirror --mirrorlog core my_vg

If you choose core, you prioritize write speed over recovery time. For small volumes, a full resync is fast, but for large volumes, it can take hours, during which your mirror is technically degraded.

If you prefer reliability, use the default disk log. It may be slightly slower due to the overhead of updating the log on disk, but it allows LVM to quickly determine which small regions need fixing after an interruption, avoiding the need for a full data copy.

Key Takeaway: Choose core log for maximum write performance at the cost of a full resync after crashes, or stick to the default disk log to ensure quick recovery and data integrity after system interruptions.