Nov 7, 2011

iSCSI and LVM: Boot problem

Both LVM and iSCSI are powerful and reliable. But there is an issue with the combination of both that made me fell completely lost more than once.

The Scenario:
iSCSI target / server is a Linux Box with LVM features
iSCSI target / server exports disk, partition or LVM LV
iSCSI initiator / client uses the exported volume as LVM PV
All works perfectly until rebooting the iSCSI target / server

The symptom:
After rebooting the iSCSI target / server, it becomes impossible for the initiator / client use the exported volume as if it were deleted. The iSCSI target / server service itself is working properly but the exported volume is not.

The cause:
During the boot of the iSCSI target / server, its LVM liked the new found PVs / VGs / LVs. The iSCSI target / server has no idea about those new found are not for the local machine and it "locks" the VGs and LVs for local use. When iSCSI exports the LV, it will contain locked LVM volumes. This is why it becomes impossible to use it on the iSCSI initiator / client.

The solution:
It is very easy. Edit /etc/lvm/lvm.conf and use "filters" to tell LVM what is not for local use. My filter is configured as:

filter = [ "a/sda/", "r/.*/" ]

For testing, just type pvscan after editing the file to see if the filter worked as expected. If so, just reboot and it will work.

Please note that using sda on the filter is not the safest solution as it is not impossible that sda becomes sdb for example. It will be safer to use UUIDs of something else.
Post a Comment