site  contact  subhomenews

Oops, fixed drive speed test at bootup

October 20, 2025 — BarryK

In the early bootup, a value is displayed which is a rough estimate of the speed of the working-drive. To improve the accuracy, I have changed it to take three readings. This is in the 'init' script in the initrd:

TIMEs1="$(dd if=/dev/${WKG_DRV} of=/dev/null bs=1024 count=64 iflag=skip_bytes skip=805306368 2>&1 | grep -o '[0-9.]* [second]*s,' | cut -f 1 -d ' ')"
TIMEs2="$(dd if=/dev/${WKG_DRV} of=/dev/null bs=1024 count=64 iflag=skip_bytes skip=1610612736 2>&1 | grep -o '[0-9.]* [second]*s,' | cut -f 1 -d ' ')"
TIMEs3="$(dd if=/dev/${WKG_DRV} of=/dev/null bs=1024 count=64 iflag=skip_bytes skip=2415919104 2>&1 | grep -o '[0-9.]* [second]*s,' | cut -f 1 -d ' ')"
TIMEs="$(dc -e "${TIMEs1} ${TIMEs2} + ${TIMEs3} + p")"
#...sata hdd: 0.018864, usb3.0 ssd: 0.003258, pcie nvme ssd: 0.001403, cheap emtec usb2 flash stick: 0.013006, sandisk ultra usb3.0 flash stick: 0.004393, usb3.0 hdd: 0.035629
TIME10k=$(dc -e"${TIMEs} 10000 * p" | cut -f 1 -d '.') #cheap flash stick: usb2=140 usb3=77, be usb3=41, sandisk-extreme usb3=42, internal eMMC:
echo "Working drive read speed test (lower the better): ${TIME10k}"

But I forgot, it is supposed to be the average of three readings, so needs to be divided by three:

TIME10k=$(dc -e"${TIMEs} 10000 * 3 / p" | cut -f 1 -d '.')

Now fixed.   

Tags: easy