The full case is the following:

  • I attach a LUN from a SAN box (iscsi configuration has been done correctly)
  • As soon as I restart the open-iscsi daemon, the LUN is attached and its name appears under /dev/mapper is something like the following string: 360060e80104dac0004f349c800000001

Now I don't want to use this alphanumeric, I need a decent mnemonic. So, I use the dmsetup command as follows: # dmsetup rename 360060e80104dac0004f349c800000001 datastore

and a datastore link to a dm device appears under /dev/mapper. Problem solved, until the next reboot. where the datastore mnemonic is gone and the above alphanumeric appears again under /dev/mapper.

How do I make this change permanent?


Consider referencing the LUN via /dev/disk/by-{id,path,uuid} instead of trying to rename WWN every time.

Or maybe you can make a udev(7) rule to create a static node under /dev representing your block device based on attributes related to your WWN. You can get all the attributes with udevadm(8). A good starting point would be ID_WWN_WITH_EXTENSION:

ENV{ID_WWN_WITH_EXTENSION}=="360060e80104dac0004f349c800000001", SYMLINK+="iscsi/datastore"

This creates a symlink at /dev/iscsi/datastore that points to your iscsi LUN.


Add the dmsetup rename entry in /etc/rc.local

echo "dmsetup rename 360060e80104dac0004f349c800000001 datastore" >> /etc/rc.local

You didn't give the OS specifics. However, most modern OSes support udev and this is a pretty good way to do what you are trying.

After assigning the lun to the system, just get the scsi_id of the disk. You need to get the sg3_utils package installed. I am talking in Red Hat and derivative terms.

/sbin/scsi_id --page=0x83 --whitelisted /dev/sdX

Replace sdx with sda or sdb or whatever.

Now, that you have the scsi_id, write a udev rule in /etc/udev/ruls.d directory.

KERNEL="sd*", BUS=="SCSI", PROGRAM=="/sbin/scsi_id -gus /dev/sd*", RESULT=="XXXX", SYMLINK+="datastore", OWNER=="username", GROUP=="groupname", MODE="0664"

I came up with the rule from scratching my memory but the syntax should be correct.

Restart udev after this or better bet, reboot.

  • -gus for rhel5 and -gud for rhel6. scsi_id has got hell lot of switches, /sbin/scsi_id --page=0x83 gives the VPD data, --page=0x80 gives manufacturer data. Select what you want – Soham Chakraborty Jan 30 '13 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.