When the USB power is too low


I have an old Raspberry Pi 3B+, which I used years ago as a simple home server and a sandbox to tinker mostly with Python. But after a few years of day-to-day usage, it went back on the shelf.

My Raspberry Pi 3B+
My Raspberry Pi 3B+ displaying weather information on a small display

Last year, I decided to try using it as a very basic Jellyfin server for my parents. I put the DietPi OS on it because it is the lightest OS for the RaspberryPi that I know about. And then I started playing with the jellyfin docker container. It works quite well. The UI is sluggish, but for a small media collection, it may be enough if you have a lot of patience.

The only problem I started having was data storage. I used an external hard drive case connected by USB and a 2,5" laptop hard drive. The thing is that this type of hard drive has different power usage between models, and my model causes problems during spin down. In some scenarios, the power delivered via USB was too low, and the partition was being dismounted from the system. The best solution would be to buy the self-powered USB hub and then connect it to the Pi, but I wanted to find a software solution to this issue. I was trying to use tools that disable the spin down feature, but they didn't work. I guess the problem there was with the chip inside the external hard drive case, which is handling the spin down by itself and ignores system commands. The final solution may look stupid, but it works. I added this line to the crontab.

*/2 * * * * root /bin/touch /mnt/hdd1 &>/dev/null

It runs every 2 minutes, uses the touch command on the mounted partition, and directs the result to /dev/null. So it doesn't actually do anything but block the hard drive from going into standby mode.