Skip to content

Instantly share code, notes, and snippets.

@oxavelar
Last active June 12, 2025 02:34
Show Gist options
  • Select an option

  • Save oxavelar/198850f6f91a3a0353f7772280bd92a2 to your computer and use it in GitHub Desktop.

Select an option

Save oxavelar/198850f6f91a3a0353f7772280bd92a2 to your computer and use it in GitHub Desktop.
Visualize disk activity using block_dump real-time
# Copy paste script to visualize disk activity in order to hunt
# and debug activity that prevents Synology disks from sleep
sudo bash -e -c "
paths=/sys/block/sata[0-9]/device/syno_idle_time
trap 'echo 0 > /proc/sys/vm/block_dump ; exit' SIGINT SIGTERM
echo \"[INFO] Enabling block_dump & monitoring Synology idle timers...\"
echo 1 > /proc/sys/vm/block_dump
last_trigger_epoch=\$(date +%s)
while true; do
triggered=0
for idle_path in \$paths; do
[ -f \"\$idle_path\" ] || continue
idle_val=\$(<\"\$idle_path\")
if [ \"\$idle_val\" -le 1 ]; then
triggered=1 ; break
fi
done
now_epoch=\$(date +%s)
if [ \"\$triggered\" -eq 1 ]; then
echo
echo \"[INFO] ------ \$(date) ------\"
grep . \$paths
dmesg --human --time-format iso | grep -vE 'on (tmpfs|proc)' || true
dmesg --clear
last_trigger_epoch=\$now_epoch
else
idle_duration=\$((now_epoch - last_trigger_epoch))
printf \"\r[INFO] Disks have been idle for %3d minutes...\" \$((idle_duration / 60))
fi
sleep 1
done
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment