Operations 6 min read

Recovering a Broken LVM Root Partition on CentOS 7

A friend’s CentOS 7 server failed to boot because the LVM‑managed root partition disappeared, and this guide walks through diagnosing the dracut error, extracting partition data from raw disk sectors, recreating the LVM backup file, and restoring the system to a bootable state.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Recovering a Broken LVM Root Partition on CentOS 7

Background

A CentOS 7 server failed to boot because the root logical volume could not be found. The root filesystem could not be mounted and attempts to repair the XFS filesystem with xfs_repair did not succeed.

Cause Analysis

During early boot the dracut environment reports /dev/mapper/centos-root does not exist. The commands lvs, vgs and vgscan return no information, indicating that the LVM metadata for the volume group centos has been lost.

Recovery Strategy

The goal is to reconstruct the missing LVM metadata. The usual method is to restore the backup files stored in /etc/lvm/backup. When those backups are unavailable, the metadata can be rebuilt manually by extracting the volume‑group description from the raw disk sectors and creating a temporary backup file that matches the original format.

Step‑by‑Step Procedure

Boot from a rescue medium . Use a CentOS LiveCD/USB or any Linux live environment so that the damaged system is not modified while you work.

Identify the physical volume . Determine which partition contains the LVM PV (in the example the PV resides on /dev/sdb3). Dump the first few sectors of that partition to verify that LVM metadata is still present: dd if=/dev/sdb3 bs=512 count=10 | hexdump -C Create a synthetic LVM backup file . Using the information obtained from the sector dump, write a file that follows the /etc/lvm/backup syntax. An example file for a volume group named centos is shown below (save it as .conf or /etc/lvm/backup/centos):

# Generated by LVM2 version 2.02.42
contents = "Text Format Volume Group"
version = 1
description = "Recreated after loss of original metadata"
creation_host = "recovery-host"
creation_time = $(date +%s)

centos {
  id = "example-id"
  seqno = 1
  status = ["RESIZEABLE", "READ", "WRITE"]
  flags = []
  extent_size = 8192
  max_lv = 0
  max_pv = 0

  physical_volumes {
    pv0 {
      id = "pv-id"
      device = "/dev/sdb"
      status = ["ALLOCATABLE"]
      flags = []
      dev_size = 21484367872
      pe_start = 384
      pe_count = 2622603
    }
  }

  logical_volumes {
    root {
      id = "lv-id"
      status = ["READ", "WRITE", "VISIBLE"]
      flags = []
      segment_count = 1
      segment1 {
        start_extent = 0
        extent_count = 76800   # 300 GB
        type = "striped"
        stripe_count = 1
        stripes = ["pv0", 0]
      }
    }
  }
}

Restore the volume‑group metadata with vgcfgrestore pointing to the file you just created: vgcfgrestore centos -f .conf Verify the restoration . Run vgs and lvs to ensure that the volume group and its logical volumes (including the root LV) are listed.

Reboot the system . After confirming that the LVs are present, reboot the machine and verify that the root filesystem mounts normally:

reboot

Key Commands

dd if=/dev/sdb3 bs=512 count=10 | hexdump -C

– dump the first 10 512‑byte sectors of the PV to inspect LVM metadata. vgcfgrestore <em>vg_name</em> -f <em>file</em> – restore a volume‑group configuration from a backup file. vgs / lvs – display the status of volume groups and logical volumes.

Result

After the restoration and reboot, the server boots normally and the root logical volume is mounted successfully.

LVM diagnostic output
LVM diagnostic output
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem AdministrationLVMCentOSRoot Partition Recovery
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.