Complete Guide to Linux Storage Commands: HBA, WWPN, WWNN, Multipath & SCSI

Managing storage in Linux systems requires a solid understanding of various commands and concepts, especially when working with enterprise storage environments using SAN (Storage Area Network), HBA (Host Bus Adapter), and multipath configurations. This comprehensive guide covers essential Linux storage commands that every system administrator should know.

📑 Table of Contents

Understanding Storage Components in Linux

Before diving into commands, let’s understand the key storage components:

  • HBA (Host Bus Adapter): A hardware component that connects servers to storage networks, typically Fibre Channel SANs
  • WWNN (World Wide Node Name): A globally unique 64-bit identifier assigned to each Fibre Channel node or HBA
  • WWPN (World Wide Port Name): A unique identifier for each FC port on an HBA
  • Multipath: Technology that provides redundant physical paths between servers and storage devices
  • LUN (Logical Unit Number): A unique identifier used to designate storage volumes

Commands to Check HBA Information

1. Finding WWPN (World Wide Port Name)

The WWPN is essential for zoning configuration in SAN environments. Here’s how to find it:

cat /sys/class/fc_host/host*/port_name

This command displays the WWPN for all HBA ports. The output typically looks like:

0x50060b0000c26604
0x50060b0000c26605

2. Finding WWNN (World Wide Node Name)

To find the WWNN of your HBA cards:

cat /sys/class/fc_host/host*/node_name

3. Check HBA Port Status

Verify if your HBA ports are online and functioning:

cat /sys/class/fc_host/host*/port_state

You should see “Online” for active ports. If you see “Linkdown” or “Offline”, there may be connectivity issues.

4. List Available HBA Ports

To see all available FC host adapters:

ls -l /sys/class/fc_host/

5. Using systool Command

The systool command (from sysfsutils package) provides detailed HBA information:

# Install sysfsutils if not available
yum install sysfsutils    # RHEL/CentOS
apt install sysfsutils    # Ubuntu/Debian

# Check port state
systool -c fc_host -v | grep port_state

# Get port names
systool -c fc_host -A port_name

# Get comprehensive HBA details
systool -c fc_host -v

6. Using lspci Command

Identify Fibre Channel HBA hardware:

lspci -nn | grep -i "fibre"
lspci -nn | grep -i "qlogic"
lspci -nn | grep -i "emulex"

SCSI Device Information Commands

1. List All SCSI Devices

lsscsi

This shows all SCSI devices with their device paths, types, and models.

2. Detailed SCSI Information

# Show size information
lsscsi -s

# Show SCSI generic device
lsscsi -g

# Show long device paths
lsscsi -L

3. Check SCSI Host Information

cat /proc/scsi/scsi

4. Rescan SCSI Bus

After adding new LUNs, rescan to detect them:

# Rescan all hosts
for host in /sys/class/scsi_host/host*; do echo "- - -" > $host/scan; done

# Rescan specific host
echo "- - -" > /sys/class/scsi_host/host0/scan

Multipath Configuration and Commands

Understanding Multipath

Device Mapper Multipath (DM-Multipath) creates a single logical device from multiple physical paths. For example, a server with two HBAs connected to a storage controller with two ports sees four paths to the same LUN.

1. Check if Multipath is Installed

# Check if module is loaded
lsmod | grep dm_multipath

# Check multipath daemon status
systemctl status multipathd

# Install multipath if needed
yum install device-mapper-multipath    # RHEL/CentOS
apt install multipath-tools             # Ubuntu/Debian

2. List Multipath Devices

The most commonly used multipath command:

# List all multipath devices
multipath -ll

# Verbose output
multipath -v2
multipath -v3    # More verbose

Sample output explanation:

mpatha (360060160000000000000000000000001) dm-0 VENDOR,MODEL
size=100G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 2:0:0:1 sdb 8:16 active ready running
| `- 3:0:0:1 sdd 8:48 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 2:0:1:1 sdc 8:32 active ready running
  `- 3:0:1:1 sde 8:64 active ready running

3. Multipath Configuration

# Generate default configuration
mpathconf --enable

# View configuration
cat /etc/multipath.conf

# Test configuration
multipath -t

4. Reload Multipath Configuration

systemctl reload multipathd

5. Flush Unused Multipath Devices

# Flush specific device
multipath -f mpatha

# Flush all unused devices
multipath -F

6. Rescan for New LUNs with Multipath

# Issue LIP (Loop Initialization Protocol) to rescan FC fabric
echo 1 > /sys/class/fc_host/host*/issue_lip

# Rescan SCSI bus
for host in /sys/class/scsi_host/host*; do echo "- - -" > $host/scan; done

# Reload multipath daemon
systemctl reload multipathd

# Verify new devices
multipath -v2

Disk and Storage Information Commands

1. List Block Devices

# Basic listing
lsblk

# Show filesystem type and UUID
lsblk -f

# Show size in bytes
lsblk -b

# Tree view with all information
lsblk -a

2. Check Disk Space Usage

# Human-readable format
df -h

# Show inode usage
df -i

# Show specific filesystem type
df -t ext4

3. Disk Partition Information

# List all partitions
fdisk -l

# Detailed partition table
parted -l

# GPT partition information
gdisk -l /dev/sda

4. Disk I/O Statistics

# Install if needed
yum install sysstat

# Show I/O statistics
iostat -x 2

# Detailed device statistics
iostat -xd 2 5

5. UUID and WWID Information

# Get UUID of devices
blkid

# Get WWID of multipath devices
/lib/udev/scsi_id -g -u -d /dev/sda

# List devices by UUID
ls -l /dev/disk/by-uuid/

# List devices by WWID
ls -l /dev/disk/by-id/

Advanced Storage Commands

1. Check Fibre Channel Statistics

cat /sys/class/fc_host/host*/statistics/*

2. Monitor Path Failures

# Check multipath path status
multipath -ll | grep -i "failed|faulty"

# Monitor multipathd daemon logs
journalctl -u multipathd -f

# Check system logs for storage errors
dmesg | grep -i "scsi|multipath"

3. Storage Device Performance

# Test disk read speed
hdparm -t /dev/sda

# Test cache read speed
hdparm -T /dev/sda

# Detailed SMART information
smartctl -a /dev/sda

4. LVM Commands for Storage Management

# Display physical volumes
pvdisplay

# Display volume groups
vgdisplay

# Display logical volumes
lvdisplay

# Scan for new PVs
pvscan

# Extend logical volume
lvextend -L +10G /dev/mapper/vg01-lv01
resize2fs /dev/mapper/vg01-lv01

Troubleshooting Common Storage Issues

Issue 1: New LUNs Not Detected

Solution:

# Rescan FC fabric
echo 1 > /sys/class/fc_host/host*/issue_lip

# Rescan SCSI hosts
for host in /sys/class/scsi_host/host*; do echo "- - -" > $host/scan; done

# Check if devices appear
lsscsi
multipath -ll

Issue 2: Multipath Paths Showing as Failed

Solution:

# Check path status
multipath -ll

# Check HBA port state
cat /sys/class/fc_host/host*/port_state

# Reload multipathd
systemctl restart multipathd

# Check SAN switch zoning and cable connections

Issue 3: Disk I/O Performance Problems

Solution:

# Monitor I/O wait
top    # Look for high %wa

# Check I/O statistics
iostat -x 2

# Verify multipath load balancing
multipath -ll

# Check for SCSI errors
dmesg | grep -i error

Best Practices for Linux Storage Management

  1. Always use multipath for SAN storage to ensure high availability and load balancing
  2. Document WWPN/WWNN information for all HBAs before SAN zoning configuration
  3. Regular monitoring of multipath status to detect path failures early
  4. Use persistent device names (UUID or WWID) in /etc/fstab instead of /dev/sdX
  5. Test failover scenarios to ensure multipath is working correctly
  6. Keep multipath.conf optimized for your specific storage vendor
  7. Monitor logs regularly for storage-related errors
  8. Maintain proper zoning on SAN switches to prevent security issues

Conclusion

Understanding and mastering these Linux storage commands is crucial for managing enterprise storage environments. From checking HBA information with WWPN and WWNN to configuring multipath and troubleshooting storage issues, these commands form the foundation of Linux storage administration.

Whether you’re managing a small server with local storage or a large enterprise SAN infrastructure, these commands will help you efficiently monitor, configure, and troubleshoot your Linux storage systems. Practice these commands in a test environment first, and always maintain proper documentation of your storage configuration.

By implementing these best practices and commands, you’ll be well-equipped to handle various storage scenarios in production Linux environments.

Frequently Asked Questions (FAQs)

1. What is the difference between WWNN and WWPN?

WWNN (World Wide Node Name) is a unique identifier for the entire HBA card, while WWPN (World Wide Port Name) is a unique identifier for each individual port on the HBA. A single HBA with two ports will have one WWNN but two WWPNs.

2. How do I check if multipath is working correctly?

Use the command multipath -ll to list all multipath devices. Check that multiple paths are shown for each device and their status is “active ready running”. You should see at least two paths per device in a properly configured multipath setup.

3. Why should I use multipath for SAN storage?

Multipath provides redundancy and load balancing for SAN storage. If one path fails due to HBA, cable, or switch failure, I/O automatically continues through alternate paths without disruption. It also improves performance by distributing I/O across multiple paths.

4. How can I rescan for new LUNs without rebooting?

Run the following commands: echo 1 > /sys/class/fc_host/host*/issue_lip to rescan the FC fabric, then for host in /sys/class/scsi_host/host*; do echo "- - -" > $host/scan; done to scan for new devices, and finally systemctl reload multipathd to update multipath devices.

5. What command shows the physical path for each multipath device?

The command multipath -ll displays all multipath devices along with their underlying physical device paths (like sdb, sdc, etc.) and shows which paths are active and their priority.

6. How do I find the WWID of a disk?

Use the command /lib/udev/scsi_id -g -u -d /dev/sda (replace sda with your device). You can also use multipath -ll which displays WWIDs in parentheses for each multipath device.

7. What does ‘queue_if_no_path’ mean in multipath configuration?

The ‘queue_if_no_path’ feature tells the system to queue I/O requests if all paths to a device fail, rather than returning I/O errors immediately. This prevents application failures during temporary path outages, waiting for paths to recover.

8. How can I monitor multipath path failures in real-time?

Use journalctl -u multipathd -f to monitor the multipathd daemon logs in real-time. You can also check dmesg | grep -i multipath for recent multipath events and path state changes.

Was this article helpful?

RS

About the Author: Ramesh Sundararamaiah

Red Hat Certified Architect

Ramesh is a Red Hat Certified Architect with extensive experience in enterprise Linux environments. He specializes in system administration, DevOps automation, and cloud infrastructure. Ramesh has helped organizations implement robust Linux solutions and optimize their IT operations for performance and reliability.

Expertise: Red Hat Enterprise Linux, CentOS, Ubuntu, Docker, Ansible, System Administration, DevOps

Add Comment