Revised code to test drive speed in initrd
January 02, 2026 —
BarryK
The 'init' script in the initrd takes three spot speed readings, using the 'dd' "skip" feature. The intention of this is that on a HDD it will cause slow readings as the physical arm will have to move to different tracks on the magnetic platters. However, I have a suspicion that skip causes weirdness with SSDs.
So, have changed the code to just one one 118MB read, without skip:
###speed test###
###############################################################################
#note: dd in coreutils has different output, "s" instead of "seconds"...
##get average of three timings...
#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 * 3 / p" | cut -f 1 -d '.') #cheap flash stick: usb2=140 usb3=77, be usb3=41, sandisk-extreme usb3=42, internal eMMC:
#20260102 suspicion dd skip causing weirdness on ssd's, just do one big read...
sleep 0.1
TIMEs="$(dd if=/dev/${WKG_DRV} of=/dev/null bs=1M count=118 2>&1 | grep -o '[0-9.]* [second]*s,' | cut -f 1 -d ' ')"
TIME10k=$(dc -e"${TIMEs} 100 * p" | cut -f 1 -d '.')
echo "Working drive read speed test (lower the better): ${TIME10k}"
I only have three computers to test on; had several but recently
gave them away and binned a couple of very old ones. Have done a
radical cleanup of my premises. Anyway, testing on two of my
computers, Zenbook and Aspire3 laptops, giving consistent results.
Tags: easy