When a LUN detach is attempted from the vSphere Client or the ESXi Host Client it fails with the generic error: "Cannot change the host configuration"
Executing the command esxcli storage core device detached list
on the affected host may return no devices or less than 1024 devices.
To count the devices in this list the command esxcli storage core device detached list | wc -l
can be run on SSH of affected host.
VMware vSphere ESXi 7.x
Each LUN which is detached from the ESXi host will have its configuration persist on the host.
This LUN would appear in the detached device list. For ESXi 6.7 and above the number of devices which can persist in the detached list is 1024.
Thus after detaching 1024 LUNs from the ESXi host, the 1025th LUN's detach operation will fail. vmkernel.log of the affected host will show the below logging:
YYYY-MM-DDTHH:MM:SS.SSSZ cpu15:68121 opID=c3055eb6)WARNING: ScsiDevice: 8612: Detach failed for device: naa.############. Exceeded the number of devices that can be detached. Clean up all stale detach entries.
To resolve this issue the LUNs which had been previously detached should be removed from the detached device list.
Steps to resolve the issue:
First validate if there are entries already present in the detached list of the ESXi host and if it is at 1024 LUNs/devices: esxcli storage core device detached list | wc -l
This command counts the number of lines in the output of command esxcli storage core device detached list
.
Validate if the LUN is set to perennially reserved state by running command: esxcli storage core device list -d <device id>
Where <device id> is the naa/t10/eui id of the device from the detached list of step 1 commands output. If the "Is Perennially Reserved" parameter is "true" for the device then:
Set it to "false" by using command: esxcli storage core device setconfig -d <device id> --perennially-reserved=false
If it is at 1024 devices, then clear the entries from this list by running the command: esxcli storage core device detached remove -d <device id>
Where <device id> is the naa/t10/eui id of the device from the detached list of step 1 commands output.
Repeat step 3 till the detached list is empty.
Post this the LUN whose detach task was failing will get detached successfully.
Make sure that the perennially reserved flag is only removed from LUNs that do not exist in the environment anymore. If you remove the flag of a LUN that is currently used as RDM, the next time the ESXi is booted it will experience long time to start as per KB ESXi host takes a long time to start during rescan of RDM LUNs.