Changing a virtual machines RDM Logical Unit Number (LUN) to Read-Write mode fails and remains in a Read-only/Write Protected state
search cancel

Changing a virtual machines RDM Logical Unit Number (LUN) to Read-Write mode fails and remains in a Read-only/Write Protected state

book

Article ID: 341534

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

Symptoms:

After changing the Logical Unit Number (LUN) state from Read-Only to Read-Write, the following symptoms appear:
  • Performing a rescan of the storage array fails to update the LUN
  • In the /var/log/vmkernel.log file, there are sense codes:

    0x7 0x0 0x0

  • The virtual machine is unable to write to the attached RDM.



Environment

VMware vSphere ESXi 6.x
VMware vSphere ESXi 7.x
VMware vSphere ESXi 8.x

Cause

This issue occurs when cached INQUIRY data is not updated with the new LUN state and is passed to the guest OS.

Resolution

To resolve this issue reset the LUN to the actual LUN ID in which the state was changed:

 

  1. Connect to the host using the SSH and log in with root credentials Using ESXi Shell in ESXi.
  2. Run this command to reset the LUN:

    vmkfstools -L lunreset /vmfs/devices/disks/
    LUN_ID

    As an example of these messages in the /var/log/vmkernel.log file:

    <YYYY-MM-DD>T<time>Z cpuXX:XXXXX)WARNING: NMP: nmpDeviceTaskMgmt:XXXX: Attempt to issue lun reset on device LUN_ID . This will clear any SCSI-2 reservations on the device.

    <YYYY-MM-DD>T<time>Z cpuXX:XXXXX)Resv: 631: Executed out-of-band lun reset on LUN_ID
    <YYYY-MM-DD>T<time>Z cpuXX:XXXXX)ScsiCore: 1486: Power-on Reset occurred on vmhbaX:CX:TX:LXXX</time></time></time>


  3. Run this command to reclaim the LUN:

    esxcli storage core claiming reclaim -d LUN_ID

    Note: This command will fail if there is I/O currently being sent to the device.

  4. If the virtual machine is still unable to write to the LUN, try each of these options individually:
    • Unmount, detach, and reattach the LUN to the host. For more information, see How to detach a LUN device from ESXi hosts.

      Note: This command may fail if there is I/O currently being sent to the device and a host reboot may be required.

    • Unpresent and re-present the LUN to the ESXi host from the storage array side.

      Important: If uncertain of the consequences/impact this action will have on the environment, contact the storage vendor for further assistance.

Additional Information

If the state of the LUN needs to change from Read Only (RO) to Read Write (RW), or vice versa, do it before presenting the LUN to the ESXi host - or unmount the datastore/RDM before making the state change on the storage side see, How to detach a LUN device from ESXi hosts

Impact/Risks:
* Changing the LUN write state from Read Write to Read Only "on the fly" while it is still being in use might cause data corruption on the device filesystem so this kind of change should never be done on a live datastore/Raw Device Map.