How to remove corrupted PV in Linux OS

Introduction: In a Logical Volume Management (LVM) setup, a corrupted Physical Volume (PV) can lead to data loss and system instability. Fortunately, handling such situations effectively can prevent further damage and restore system integrity. In this article, we'll outline the steps to identify and remove a corrupted PV from your LVM configuration.

Identifying the Corrupted PV:

  1. Utilize pvdisplay or pvs Command:
    • Begin by using the pvdisplay or pvs command to enumerate the PVs present in your system.
    • These commands provide essential information about each PV, aiding in the identification of the corrupted one.

Checking VG Status: 2. Verify Volume Group (VG) Status:

  • After identifying the potentially corrupted PV, it's crucial to assess its impact on the associated Volume Group (VG).
  • Use the vgdisplay command to examine the status of the VG and ascertain whether the corrupted PV remains a member.

Checking for Error Messages: 3. Review System Logs for Error Messages:

  • Error messages and warnings associated with the PV can offer insights into its state and potential corruption.
  • Explore system logs using commands like dmesg and journalctl to identify any pertinent messages related to the PV.

Example Commands:

  • dmesg | grep "PV_NAME": Searches system message logs for occurrences of the PV's name, providing context on potential issues.
  • journalctl -xe: Examines system-wide journal logs, highlighting any errors or warnings pertinent to the PV's status.
-------------------------------------------------
Before proceeding with any operations, ensure that the file system associated with the PV is unmounted. Use the following command:
Unmount the File System
umount <filesystem>

To check space used by the physical volumes.
pvs -o+pv_used

Extend VG
It's required add extra space before removing PV, to extend vg 
> add disk with required space.
>  create PV
pvcreate /dev/sde
> now extend VG, 
vgextend vg_data /dev/sde
Move PV
Now, it’s time to transfer the data from the corrupted PV to the newly added PV. Execute:
pvmove /dev/sdc /dev/sde
Ensure that the PV space is correctly allocated and then reduce the VG space by removing the corrupted PV. Utilize the following commands:
pvs -o+pv_used
vgreduce vg_data /dev/sdc
It's done, now you can mount your file system, verify it. 
mount /dev/vg_data/lv_data /Lilli/LVM/
After confirming the successful mount, you can safely remove the corrupted PV from the VG as it is no longer needed. 
That's it....

Please provide your feedback below.

Comments

Popular posts from this blog

Awk command with simple examples

Learn Linux in Telugu | Linux complete Free Course in Telugu by 7Hills

rsync Command Examples | rsync Command In Telugu