0

1I'm trying to remove a physical volume from a VG

sudo vgreduce mirrorgroup /dev/sdb1

I made two PV sdb1 and sdb2 and mirrored this based on the activity I'm performing.

I needed to simulate a drive failure and this requires me to deactivate the LV and remove one of the PV (sdb1 or sdb2) but it outputs that both are still in use:

Physical volume /dev/sdb1 still in use

How can I do this?

To do: Simulate Drive Failure: Unmount the LV and deactivate it (lvchange -a n /dev/mirrorgroup/mirrorlv). Now, simulate a drive failure by removing one of the PVs from the VG using vgreduce /dev/mirrorgroup /dev/sdb1 (assuming /dev/sdb1 is the one being "removed").

shell session screenshot

lvdisplay

enter image description here

PS. I am running it on virtualbox and i thin kafter removing the PV i have to return it to simulate that i can access the files in it again

1 Answers1

1

You can't simulate drive failure that way. Linux is safeguarding you against the apparently wrong action. And, this "safe remove" is not what is seen by the system when the drive actually fails. Drive never says "please, gracefully remove me from the group because I am going to fail". It just suddenly stops responding or starts outputting errors or returns corrupted data. You need to inject such errors somehow to let the system to act on them.

Easiest is just pull one device. It's scary, I know, but at the same time it's the most plausible.

You can unregister a device using sysfs, that will make it disappear from the system:

echo 1 > /sys/block/sdb/device/delete

This would look pretty much like SSD controller died and it fell off the bus. There are other ways to do similar thing, depending on your exact system structure (e.g. if each disk is connected to separate controller, you may unregister one controller from PCI bus instead).

Also, you can use device mapper error and flakey targets to simulate I/O errors on some blocks (see this question, and answers, for example; Gentoo Wiki page about Device Mapper looks very good)), but to implement this you still need to break your setup and add this "flakey" layer below one of your PVs. This would look to the system very similar to what happens when HDD starts to show bad blocks.