When working with Linux systems, especially servers or storage-heavy environments, knowing exactly what storage devices are attached is crucial. Here are several reliable methods that work regardless of whether drives have partitions or not:
# Method 1: Using lsblk (most recommended)
lsblk -d -o NAME,ROTA,RM,SIZE,MODEL,TRAN
# Sample output:
NAME ROTA RM SIZE MODEL TRAN
sda 1 0 1.8T WDC WD2003FYYS-2 ATA
nvme0n1 0 0 500G Samsung SSD 970 nvme
For more detailed information about each device:
# Method 2: Querying udev database
ls -l /dev/disk/by-id/
# Method 3: Using lshw (requires root)
sudo lshw -class disk -short
# Method 4: Checking sysfs directly
ls /sys/block/ | grep -Ev "loop|ram"
For systems with NVMe devices or complex storage setups:
# NVMe specific listing
nvme list
# SCSI/SATA devices with smartctl
for device in /dev/sd?; do
sudo smartctl -i $device | grep -E "Device Model|Serial|User Capacity"
done
While /proc/partitions shows partition information, you can combine it with other data:
# Enhanced /proc parsing
grep -E "sd[a-z]$|nvme[0-9]n[0-9]$" /proc/partitions | awk '{print $4}'
This script combines multiple methods for a complete picture:
#!/bin/bash
echo "=== Storage Device Report ==="
date
echo -e "\n[Physical Devices]"
lsblk -d -n -o NAME,ROTA,RM,SIZE,MODEL,TRAN,VENDOR | grep -v "loop"
echo -e "\n[Partition Information]"
lsblk -o NAME,FSTYPE,MOUNTPOINT,LABEL,UUID
echo -e "\n[Device Details]"
for dev in $(lsblk -d -n -o NAME); do
echo -e "\nDevice: /dev/$dev"
udevadm info -q property -n $dev | grep -E "ID_MODEL=|ID_SERIAL="
done
There are several robust methods to detect all storage devices in Linux, regardless of their partition status:
# 1. Using lsblk (recommended for most cases)
lsblk -d -o NAME,MODEL,SIZE,ROTA,TRAN,TYPE
# 2. Checking /dev/disk entries
ls -l /dev/disk/by-id/ | grep -v part
# 3. Comprehensive lshw output
sudo lshw -class disk -short
The Linux kernel exposes storage devices through multiple interfaces. While /proc/partitions
shows partitioned devices, these alternatives provide more complete information:
# Check kernel messages for detected devices
dmesg | grep -i 'sd\\|hd'
# View SCSI/SATA devices specifically
cat /proc/scsi/scsi
# Alternative with detailed information
sudo hdparm -I /dev/sdX # Replace X with your device letter
For scripting or detailed analysis, consider these approaches:
# JSON output (requires jq)
lsblk -d -J | jq '.blockdevices[] | select(.type=="disk")'
# Using udev for detailed properties
udevadm info --query=all --name=/dev/sda | grep -E 'ID_MODEL|ID_SERIAL'
# NVMe-specific detection
nvme list
If a device isn't appearing in listings:
# Rescan SCSI bus
echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan
# Check for missing kernel modules
lsmod | grep -E 'ahci|sd_mod|nvme'