VMware Cloud Community
baber
Expert
Expert

How can disable hba card from esxcli or vsphere

DEar all

hi

i have 2 hba card on my esxi server but just one of them is usefull and i want disable one of them from esxi command line

i know there is a command for disable nic card now how can disable one of my hba card?

Please mark helpful or correct if my answer resolved your issue.
0 Kudos
4 Replies
luxrajah
Contributor
Contributor

You might be better off disabling it in BIOS. esxcli command may end up disabling both HBA if it's not handled correctly. You can go in to BIOS and under PCI devices, you can disable this and that will be better for ESXi boot as well.

0 Kudos
yunya09
Enthusiast
Enthusiast

Disable hba card is dangerous ,before you execute ,you should confirmed clear.

example:  if you want disable vmhba4

hbabefore.png

login esxi with root

~ # esxcli storage core path list |grep -C 6  vmhba4 |grep UID

   UID: fc.20000024ff59407a:21000024ff59407a-fc.5000144047605366:50001442a0536601-naa.6000144000000010705366d9d122ef47

   UID: fc.20000024ff59407a:21000024ff59407a-fc.5000144047605366:50001442a0536601-naa.6000144000000010705366d9d122ef42

   UID: fc.20000024ff59407a:21000024ff59407a-fc.500014404770559f:50001442b0559f01-naa.6000144000000010705366d9d122ef47

   UID: fc.20000024ff59407a:21000024ff59407a-fc.500014404770559f:50001442b0559f01-naa.6000144000000010705366d9d122ef42

   UID: fc.20000024ff59407a:21000024ff59407a-fc.500014404760559f:50001442a0559f01-naa.6000144000000010705366d9d122ef47

   UID: fc.20000024ff59407a:21000024ff59407a-fc.500014404760559f:50001442a0559f01-naa.6000144000000010705366d9d122ef42

   UID: fc.20000024ff59407a:21000024ff59407a-fc.5000144047705366:50001442b0536601-naa.6000144000000010705366d9d122ef47

   UID: fc.20000024ff59407a:21000024ff59407a-fc.5000144047705366:50001442b0536601-naa.6000144000000010705366d9d122ef42

~ # esxcli storage core path  set --state=off -p fc.20000024ff59407a:21000024ff59407a-fc.5000144047705366:50001442b0536601-naa.6000144000000010705366d9d122ef42

do this one by one  ,untill up 8 UID value excute .Command execution without restart,effective immediately.

PS: if want turn back , --sate=active .

hbaafter.png

0 Kudos
SeeSiteCanCom
Contributor
Contributor

Just use a PowerShell Script to Deactivate or Acticate all PATHs from a specific FC HBA:

# Targethostname from the vCenter ESXi Name
$TargetHost = "HOSTNAME"

# Target FC HBA Name, like "vmhba4"
$TargetHBA = "FCHBANAME"

# TargetPathState of all the LUNs/Paths from the specific HBA ("Off" or "active")
$TargetState = "off"

# Targetpath for the summaryfile, which will be created afterwords
$TargetFilePath = "J:\Documents\"

$AnfrageDatum = Get-Date -format yyyyMMdd
$esxcli = Get-VMHost -Name $TargetHost | Get-EsxCli -V2

$AllPaths = $esxcli.storage.core.path.list.invoke() | where {$_.Adapter -eq $TargetHBA} | Select-Object -Property Adapter, State, UID | where {$_.State -ne $TargetState}

ForEach ($LunPath in $AllPaths)
{
IF ($esxcli.storage.core.path.set.invoke(@{state=$TargetState;path=$LunPath.UID}))
{
Write-Host "Es wird vom HBA=$TargetHBA der Pfad=$($LunPath.UID) auf den Status=$TargetState gesetzt"
}
Start-Sleep -Seconds 2
}

$Ergebnis = $esxcli.storage.core.path.list.invoke() | where {$_.Adapter -eq $TargetHBA} | Select-Object -Property Adapter, State, UID
$Ergebnis
$Ergebnis | Export-Csv -Path ($TargetFilePath + $AnfrageDatum + "-Show-$TargetHBA-PathState.csv") -UseCulture

0 Kudos
omerfcolakoglu
Contributor
Contributor

Hello

You can turn it off with the following command.

In the "vmhbaX" X section, write the relevant ID of which path you want to close.

for i in `localcli storage core path list | grep "Runtime Name: vmhbaX" | awk '{print $NF}'`; do localcli storage core path set --state off --path $i; done

Tags (1)
0 Kudos