ubuntu – iSCSI Device Mapped to Different SCSI Device

iscsilvmUbuntu

I have an iSCSI disk array connected to a server (Ubuntu). When I login with

iscsiadm -m node --login -p 192.168.1.240

the device used to appear as /dev/sdb. I created a volume group with LVM using /dev/sdb, and eventually ext4 partitions on it. After a reboot the device is appearing as /dev/sdd, and I can no longer mount any of the partitions I had created. vgscan can see the VG (called a), but the devices mapped onto the partitions give an error:

vgscan
...
/dev/dm-9: read failed after 0 of 4096 at 4096: Input/output error
Found volume group "a" using metadata type lvm2

I would have thought that the system would be able to cope by itself with such a change (via the uuid of the devices), but I'm obviously missing something. So my questions are:

  • is there a way to force my iSCSI device to go back to /dev/sdb?
  • if not, is there a way to point my dev/dm-n devices to use /dev/sdd
  • what is a robust way to go about it? I have learned today how to make my iSCSI device appear with the same name (say, /dev/iscsi/array): is this what I should have done? The issue of the iSCSI device not appearing back on the same /dev/sdx device is not mentioned anywhere as far as I can tell, so perhaps I'm missing something else.

Addition: rebooting the machine has the desired effect. The device reappears at the right place. The questions remain: I'd appreciate it if anybody had any pointers so they can be answered.

Best Answer

I'm answering my own questions after some further research.

  • First of all, as far as I can tell, one cannot affect on which sdx device a given SCSI device will appear. The decision is take by the kernel. One solution is, as pointed out by Andreas Florath, to use a more permanent name. So the answer to the first bullet is NO.
  • If the device has changed name and you get dm-n errors, refresh the volume group with vgchange VGNAME --refresh and the errors will go away. Now you can mount the logical volumes as you used to.
  • A robust manner to go about the problem is to identify a persistent device ID before starting with LVM. The uuid-type of names are however not the most convenient to use. Then follow a recipe like the one given here http://jablonskis.org/2011/persistent-iscsi-lun-device-name/ to have udev create a name like /dev/iscsi/NAME.
Related Question