Sunday, June 8, 2014

Bash Script to determine capacity of a SCSI device

Please use above script to determine the capacity or device size of your SCSI device like Hard Disk (sda) or CD-ROM (sr0).
Copy the script into a script file e.g and run as below:

./readcap /dev/sda

Above command determines capacity of Hard Disk.


#This script display the SCSI device capacity you are quering about !!
#e.g. usage: ./readcap /dev/sda
ls $1 2>/dev/null 1>/dev/null
if [ $(echo $?) -eq 0 ]
sudo sg_readcap  $1 | tail -1 | awk 'BEGIN{ORS ="";print "SCSI Device Capacity: "}{print $7;ORS="\n"}END{print " GB"}'
echo "Wrong SCSI device entered/Incorrect usage of script"

Guys please report me back any issues found during script execution.

No comments:

Post a Comment