knktc's Notes

python, cloud, linux...

0%

Clean Up Leftover dmraid Metadata

I recently ran into a problem where a server’s sdb disk kept getting claimed by LVM, so I could not mount it freely by partition. Formatting also complained that the disk was in use. After some research, I found that leftover dmraid metadata was probably the cause.

dmraid stands for Device Mapper RAID. It uses the Linux kernel’s device-mapper mechanism to provide device files for various RAID implementations, allowing hardware RAID devices to be used from Red Hat Enterprise Linux and similar systems.

Instead of going into all the background details, here is the practical cleanup process.

To erase the leftover dmraid metadata from /dev/sdb, use the following steps:

  1. Check the current dmraid information:
1
dmraid -r

At this point, you should be able to see that /dev/sdb belongs to a dmraid set.

  1. Deactivate the dmraid device:
1
dmraid -a n [raid_device]

If you do not specify a RAID device file, all detected dmraid devices on the system will be marked inactive.

  1. Try removing the dmraid mapping:
1
dmraid -x [raid_device]

This step is only a best effort, because in many cases the RAID entry still cannot be removed cleanly. At that point, you can simply reformat /dev/sdb. After formatting and rebooting, the device should no longer be automatically claimed by LVM.

如果我的文字帮到了您,那么可不可以请我喝罐可乐?