Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license CC4-BY
posted in category Systems Software / GNU Linux
posted at 07. Dec '24

Howto Prevent USB HDD Going To Sleep

Some SATA to USB enclosures or convertors will make hard disk sleep after a certain amount of inactivity like 15 minutes. Usually it is not a problem, but it is when I wanted to run long S.M.A.R.T. test, because it would be interrupted when disk went to sleep.

I assume the disk is readable and writable, otherwise the solution would be harder.

Run this:

while true; do echo "aaaa" >> /mnt/aaa.txt; sleep 10; done

You cannot read same file, because Linux will cache it to RAM and the disk will go to sleep.

And then in a different terminal SMART test:

smartctl -t long /dev/sda

and then to see the result:

smartctl -a /dev/sda

And that’s all.

Add Comment