This guide outlines the steps to recover software RAID arrays and LVM volumes after a system reinstall or similar scenario where the storage configuration needs to be reactivated.
Table of Contents
1. Prerequisites
First, install the necessary packages:
sudo apt-getupdate
sudo apt-getinstall mdadm lvm2
2. Identifying RAID Arrays and LVM Volumes
Check for RAID Arrays:
# Check for existing RAID arrayssudo mdadm--detail--scan
sudo cat/proc/mdstat
Identify LVM Configuration:
# Examine partition types to identify RAID and LVM memberssudo blkid# Check for LVM physical volumessudo pvs# Check volume groupssudo vgs# Check logical volumessudo lvs# Get detailed information about physical volumessudo pvdisplay--maps
3. Activating RAID Arrays
# Assemble all detected RAID arrayssudo mdadm--assemble--scan# Verify successful assemblysudo cat/proc/mdstat# Get detailed information about a specific RAID array
# Replace md0 with the actual device name if differentsudo mdadm--detail/dev/md0
If the normal assembly fails, you can try forcing it:
# Only use this if normal assembly failssudo mdadm--assemble--force/dev/md0/dev/nvme1n1p3/dev/nvme3n1p3
4. Activating LVM Volumes
# Scan for volume groupssudo vgscan# Activate all volume groupssudo vgchange-ay# Verify all logical volumes are availablesudo lvs-a
If specific volumes need to be activated:
sudo lvchange-ay vg_name/lv_name# For example:sudo lvchange-ay vg_home/lv_home
5. Mounting the Volumes
# Create mount points if they don't existsudo mkdir-p/mnt/home/mnt/home_lfs/mnt/storage/mnt/trash# Mount the logical volumessudo mount/dev/vg_home/lv_home/mnt/home
sudo mount/dev/vg_home_lfs/home_lfs/mnt/home_lfs
sudo mount/dev/vg_storage/lv_storage/mnt/storage
sudo mount/dev/vg_trash/lv_trash/mnt/trash# Verify successful mountingdf-h
6. Making Mounts Permanent (Optional)
To make these mounts permanent across reboots, add them to the /etc/fstab
file:
# First, get the UUID of each logical volumesudo blkid|grep/dev/mapper# Then add entries to /etc/fstabsudo vim/etc/fstab
Add lines similar to the following:
/dev/mapper/vg_home-lv_home/mnt/home ext4 defaults0 2
/dev/mapper/vg_home_lfs-home_lfs/mnt/home_lfs ext4 defaults0 2
/dev/mapper/vg_storage-lv_storage/mnt/storage ext4 defaults0 2
/dev/mapper/vg_trash-lv_trash/mnt/trash ext4 defaults0 2
7. Troubleshooting
If RAID Assembly Fails:
# Check RAID details even if not activesudo mdadm--examine/dev/nvme1n1p3/dev/nvme3n1p3# Create the array manually if neededsudo mdadm--create/dev/md0--level=0 --raid-devices=2 /dev/nvme1n1p3/dev/nvme3n1p3
If LVM Volumes Are Not Found:
# Scan physical devices for LVM metadatasudo pvscan# Force a volume group scansudo vgscan--mknodes# Check for specific volume group infosudo vgdisplay vg_name
If Volumes Won’t Mount:
# Check the filesystem typesudo file-s/dev/mapper/vg_name-lv_name# Try to repair the filesystem if neededsudo fsck-f/dev/mapper/vg_name-lv_name
8. Quick Recovery Commands
For quick recovery, the minimal command set is:
sudo apt-getupdate&&sudo apt-getinstall-y mdadm lvm2
sudo mdadm--assemble--scan
sudo vgscan
sudo vgchange-ay
sudo lvs-a# Create mount points and mount volumes as needed
This guide covers the basics of recovering your specific RAID and LVM configuration. Adjust commands as needed for your particular setup.
For your specific configuration with RAID-0 on nvme1n1p3 and nvme3n1p3, and LVM volume groups vg_home, vg_home_lfs, vg_storage, and vg_trash, these commands should restore your storage setup after a system reinstall.