Saturday, August 8, 2015

convert ata.X to sdX device

 ls -l /sys/block/sd* | sed -e 's@.*-> \.\.@/sys@' -e 's@/host@ @' -e 's@/target.*/@ @'   \
| while read Path HostNum ID
   do
      echo ${ID}: $(cat $Path/host$HostNum/scsi_host/host$HostNum/unique_id) 
   done

Or more simple version
ls -l /sys/block/sd* | sed -e 's@.*-> \.\..*/ata@/ata@' -e 's@/host@ @' -e 's@/target.*/@ @'

Result:
# ls -l /sys/block/sd* | sed -e 's@.*-> \.\..*/ata@/ata@' -e 's@/host@ @' -e 's@/target.*/@ @'
/ata3 3 sda
/ata3 3 sdb
/ata4 4 sdc



http://serverfault.com/questions/244944/linux-ata-errors-translating-to-a-device-name#

No comments:

Post a Comment