Skip to content

Linux - Block Storage

Commands

ISCSI

List volumes:

lsblk
# Or
fdisk -l
# Or
blockdev --report

Display scsi devices:

cat /proc/scsi/scsi

Scan devices:

for h in $(ls /sys/class/scsi_host/); do echo "- - -" > /sys/class/scsi_host/$h/scan; done

Delete scsi device:

echo 1 > /sys/class/scsi_device/4\:0\:0\:0/device/delete

Delete lun device:

echo 1 > /sys/block/sdf/device/delete

Fiber Channel

List fiber devices:

lspci -nn | grep Fibre

Retrieve host info with path:

find /sys | grep  "15:00.0" | grep port_name

Display port name of a FC host:

cat /sys/devices/pci0000:00/0000:00:05.0/0000:15:00.0/host5/fc_host/host5/port_name

Display WWNs of FC hosts:

for port in /sys/class/fc_host/host[0-9]/port_name; { echo -n "$port : "; cat $port; }

Display detail of a FC card:

lspci -v -s 05:00.0

Partition

Partition detail:

fdisk -l /dev/sdb

Partition size:

fdisk -s /dev/sdb

Remove partition (Option d):

fdisk {pv-path}
# Ex:
#   fdisk /dev/sdb
#     List partitions:  p
#     Remove partition: d
#       Select Partition: {part-id}

Inform OS that partition table changes:

partprobe 

List partition:

partprobe -s

Troubleshooting

Display header of a volume:

hexdump -C {pv-path}
# Ex: hexdump -C /dev/sdd
Back to top