Linux view WWN number and common problem solving
View WWN number
To view the WWN number of CentOS 6.7, you can perform the following steps:
1. Make sure the storage device is connected.
lspci | grep -i fibre
2. Enter the command in the terminal: lsscsi and press Enter. This command displays information about connected storage devices.
lsscsi
3. Find the storage device you want to check the WWN number, and check its WWN number. The WWN number is usually given in a message of the form [X:X:X:X], where X is a hexadecimal number.
as the picture shows
4. If the storage device supports multipath (for example, using MPIO technology), there may be multiple WWN numbers. Please review all WWN numbers and note them down.
查询WWN号
ls /sys/class/fc_host/ //查询光模块
cat /sys/class/fc_host/hostX/port_name //其中X代表不同的数字
As shown in the figure
:
Usually the first number of the WWN number of the Emulex HBA card is 1, and the first number of the WWN number of the Qlogic HBA card is 2.
NOTE : In order to run the lsscsi command, you need root or sudo privileges.
View WWID number
When viewing the WWID number, different versions of the script have different viewing commands.
To query the version of the Linux system, you can use the following command to view it.
cat /etc/redhat-release
- CentOS 5.X and earlier versions use the following script commands.
for i in `cat /proc/partitions | awk {'print $4'} | grep sd`
do
echo "Device: $i WWID: `scsi_id -g -u -s /block/$i`"
done | sort -k4
- CentOS 6.X uses the following script commands.
for i in `cat /proc/partitions | awk {'print $4'} | grep sd`
do
echo "Device: $i WWID: `scsi_id --page=0x83 --whitelisted --device=/dev/$i`"
done | sort -k4
- CentOS 7.X uses the following script commands.
for i in `cat /proc/partitions | awk {'print $4'} | grep sd`
do
echo "Device: $i WWID: `/usr/lib/udev/scsi_id --page=0x83 --whitelisted --device=/dev/$i`"
done | sort -k4
- The CentOS8.X version uses the following script commands.
for i in `cat /proc/partitions | awk {'print $4'} | grep sd`
do
echo "Device: $i WWID: `/usr/lib/udev/scsi_id --page=0x83 --whitelisted --device=/dev/$i`"
done | sort -k4
Query FAQ
If there is -bash: scsi_id: command not found
a high probability of the query is the following situations
1. The "scsi_id" package is not installed on your system, or the command is not in your shell's search path. To install the "scsi_id" package on CentOS, you can run the following command: copy code install and target Once the package is installed, you can try running the previous command again to check the WWID of the device.
sudo yum install -y scsi-target-utils
2. If it still appears after installing the software package, -bash: scsi_id: command not found
it may be that the scsi_id directory path in the script is wrong, so we need to find the correct scsi_id directory path for query.
3. Try executing the following command to find the exact location of the scsi_id command
sudo find / -name scsi_id 2>/dev/null
4. After finding the exact location, replace it with the directory path of the above script and search again. Take my current centos6.7 version as an example.
for i in `cat /proc/partitions | awk {'print $4'} | grep sd` ;do echo "Device: $i WWID: `/usr/lib/udev/scsi_id --page=0x83 --whitelisted --device=/dev/$i`"; done | sort -k4
If the command returns no results, one of the following reasons may be the cause:
1. No eligible devices: If you do not have any SCSI devices in your system, then this command will have no output.
2. The disk is not mounted: If the device is not mounted, the command may not have output.
3. No permissions: If you do not have sufficient permissions to run the command, it may not have output. You need to use sudo or run this command as root.