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:
- Utilize pvdisplay or pvs Command:
- Begin by using the
pvdisplay
orpvs
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.
- Begin by using the
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
andjournalctl
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>
pvs -o+pv_used
Ensure that the PV space is correctly allocated and then reduce the VG space by removing the corrupted PV. Utilize the following commands:
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/sdeMove PV
Now, it’s time to transfer the data from the corrupted PV to the newly added PV. Execute:
pvmove /dev/sdc /dev/sdeEnsure 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
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.
Please provide your feedback below.
Comments
Post a Comment