which nvme &>/dev/null
if [ $? -ne 0 ];then
        yum install nvme-cli -y
fi
for DEV in `nvme list |egrep "bSSDPF21Q" |awk '{print $1}' |awk -F"/" '{print $3}' |sed 's/n1$//g'`;do
        LBA_Size=`smartctl -a /dev/$DEV |awk '/Namespace 1 Formatted LBA Size/{print $NF}' |sed 's/\s*//g'`
        FW_Ver=`smartctl -a /dev/$DEV |awk '/Firmware Version/{print $NF}' |sed 's/\s*//g'`
        if [[ "$LBA_Size" != "512" ]];then
        	nvme format /dev/$DEV -l 0
                sleep 5
        else
               	echo "$DEV $Model LBA size is already 512B"
        fi
       	if [[ "$FW_Ver" != "L0310100" ]];then
               	nvme fw-download /dev/$DEV -f L0310100_LB3B0100_WFEM01Q2_signed.bin 
                nvme fw-commit /dev/$DEV -s 1 -a 1
                sleep 5
        else 
               	echo "$DEV $Model FW is already L0310100"
        fi
done

