[CentOS] LVM and hotswap (USB/iSCSI) devices?

Sun Aug 31 14:27:50 UTC 2008
nate <centos at linuxpowered.net>

Simen Timian Thoresen wrote:

> So - with the LV unmounted, I power my USB-device down, and then back up;


I believe your problem is you didn't deactivate the logical
volume, and export the volume group before disconnecting.

lvchange -a n <path to lvm>
vgexport -a (don't worry it will only export groups that are
ready to be exported)

Now you can safely power the device down(provided the VG was
successfully exported, all logical volumes must be unmounted
and deactivated before it will succeed).

when you power it back up run

pvscan
vgimport -a
lvchange -a y <path to lvm>

LVM is very useful for volumes that change device names, but you
must use it properly otherwise bad things will happen as you
saw.

If you want to have USB mount automatically it may be better
to put a label on the file system, at least in Debian(don't
have a CentOS system with a USB disk handy here) the volume
is mounted as /media/<disk label> if there is a disk label.
You can use the e2label command to label the device. I'd
expect CentOS to likely behave similarly to debian in this
respect.

nate