In this post we are going to share about how to reset hba port in linux if required due to any reason.We will see what are hba reset command in linux available for the same.
Most of the linux systems have host bus adapter installed for SAN Disks use by server where more disks required like enterprise development or production servers.
All disk gets allocated to server from SAN and for that reason SAN card is installed which is also termed Host Bus Adapters popularly known as HBA.
HBA reset command in Linux
There might be many reason you may need to reset HBA may be because it is not recognizing newly allocated disk or due to any other reason.
So before going to reset HBA first we need to see how we can identify what HBA is installed in linux server.
How to identify hba in linux
Let us see how to identify hba in linux to have confirmation which HBA is installed on linux system.
Qlogic and Emulex are brand leaders.So this command will help unless until you have any other HBA installed in your system.
Even it is not out of these two still you can use these commands and either you can review output or grep with the name of HBA vendor.
1. # lspci |egrep "Emulex|qlc" 12:00.0 Fibre Channel: Emulex Corporation Gen6: LPe32000 Fibre Channel Host Adapter (rev 01) 86:00.0 Fibre Channel: Emulex Corporation Gen6: LPe32000 Fibre Channel Host Adapter (rev 01) 2. # dmesg |egrep "Emulex|qlc" Emulex LightPulse Fibre Channel SCSI driver 126.96.36.199 Copyright(c) 2004-2015 Emulex. All rights reserved. scsi0:Emulex LPe32000 16Gb PCIe Fibre Channel Adapter on PCI bus 12 device 00 irq 32 scsi1:Emulex LPe32000 16Gb PCIe Fibre Channel Adapter on PCI bus 86 device 00 irq 64
You might have observed there is always two HBA installed to have redundancy to have multipath configured from storage side.
So now you have your query resolved about how to identify hba is linux so let’s proceed further.
So let us see how to reset hba port in linux and see what are hba reset commands in linux to reset HBA port. Mostly QLogic and Emulex HBA in linux.
How to reset hba port – QLogic hba port reset
Basically there is utility called sg3_utils which is installed on many systems.You can check to confirm the utility installations.
# rpm -qa |grep sg3_utils sg3_utils-1.37-12.el7.x86_64 sg3_utils-libs-1.37-12.el7.x86_64
If it is not installed you can check availability of packages from yum as it is delivered with RHEL distro.
# yum --enablerepo=* list sg3_utils Installed Packages sg3_utils.x86_64 1.37-12.el7 @distro/7.3-7.el7
If you want to install use install options with above command instead of list like below.
# yum --enablerepo=* install sg3_utils This will prompt you to confirm please answer and get it installed.
Now let us see how to reset hba port for QLogic HBA.
First Method :
sg_reset command in linux
We can use sg_reset command in linux and syntax of QLogic hba reset commands in linux via sg_reset command in linux is as below.
# /usr/bin/sg_reset -H /dev/sgx # sg_reset -H /dev/sg30 Here /dev/sgx is the device via which LUNs are getting allocated.
Sample output is as below
You can verify this in messages file it will display like below
# cat /var/log/messages |grep qla Mar 9 12:00:45 hostname ker:qla2xxx[0000:14:00.1]-8018:7:ADAPTER RESET ISSUED Mar 9 12:00:46 hostname ker:qla2xxx[0000:14:00.1]-8017:7:ADAPTER RESET SUCCEEDED
Well we have gone through how to reset hba for QLogic adapter using sg_reset command.
Let us see another method how to reset HBA port in linux using
2nd Method :
issue_lip command in linux
# cat /sys/class/fc_host/host*/port_name 0x100098f2b3a14e860x100098f2b3a14ec0 If you want to reset HBA 0 # echo 1 >/sys/class/fc_host/host0/issue_lip If you want to reset HBA 1 # echo 1 > /sys/class/fc_host/host0/issue_lip
So we have seen two method for how to reset hba port in linux for QLogic host bus adapter.
How to reset hba port – Emulex hba port reset
Now let us see how to reset hba port in linux for Emulex Adapter.
First Method :
issue_lip command in linux
You can use issue_lip command for Emulex card as well.We will see another options available.
# cat /sys/class/fc_host/host*/port_name 0x100098f2b3a14e860x100098f2b3a14ec0 If you want to reset HBA 0 # echo 1 > #/sys/class/fc_host/host0/issue_lip If you want to reset HBA 1 # echo 1 > /sys/class/fc_host/host0/issue_lip Or you can simply make it offline and online using below.Please mind which hba you are going to reset. # cat /sys/class/scsi_host/host*/board_mode online online # echo offline > /sys/class/scsi_host/host0/board_mode # echo offline > /sys/class/scsi_host/host1/board_mode # echo online > /sys/class/scsi_host/host0/board_mode # echo online > /sys/class/scsi_host/host1/board_mode
2nd Method :
hbacmd commands in linux
If HBAnyware is installed on system you can use hbacmd command for managing HBA related stuff.
You can enquire if it is installed or not.
# rpm –qa |grep –I hbanyware You can use locate command in linux to find path of hbacmd command in linux. # locate hbacmd
If hbacmd command path is set in your user profile you can directly run hbacmd else you have to use absolute path.
See below sample listing HBA installed using hbacmd command in linux.
# /usr/sbin/hbanyware/hbacmd listHBA Manageable HBA List Port WWN : 10:00:00:00:c9:9c:7e:22 Node WWN : 20:00:00:00:c9:9c:7e:22 Fabric Name: 10:00:50:eb:1a:5e:93:00 Flags : 8000fe00 Host Name : server26 Mfg : Emulex Corporation Serial No. : BT00587794 Port Number: n/a Mode : Initiator
How to reset hba port using hbacmd commands in linux.You can reset specific HBA using hbacmd commands .
Please refer hba reset command in below example.
# hbacmd RESET <WWPN> # /usr/sbin/hbanyware/hbacmd Reset 10:00:00:00:c9:9c:7e:22 Reset HBA 10:00:00:00:c9:9c:7e:22 # /usr/sbin/hbanyware/hbacmd Reset 10:00:00:00:c9:9c:7a:f8 Rest HBA 10:00:00:00:c9:9c:7a:f8
That`s it about how to reset hba port in linux using issue_lip command, sg_reset command and hbacmd command in linux.
I think you will find it useful related to reset hba port in linux.If you like our work request you to like and subscribe our blog to have alerts about new posts posted immediately.
Other Similar Articles you may like…