USB External HD Becomes ReadOnly with RPI

I have a 1st Generation B model RaspberryPI with 512megs of RAM. I have Dietpi 6.17 install and updated. I attached a Sabrent USB 3.0 SATA Hard Drive Flat Docking Station with external power and a 500gig 2.5 drive. When I first used attached the USB docking station everything worked great using “Dietpi-drive_manager” to find the drive, wipe and format it with EXT4, and move my dietpi_userdata to the drive. However, the next day when I went to write to the external drive by running the command “mkdir /mnt/dietpi_userdata/newdirectory” this command hung and never completed, but before that I could “ls” and see the content of “/mnt/dietpi_userdata/”. After rebooting the RPI and power cycling the external docking station, I could once again “mkdir” and I even successfully ran “rdiff-backup” from a client computer to the RPI and wrote the files to the external drive. 4 hours later I once again can’t “mkdir”, I get the warning that the drive is “read only” even though I have never set this using the dietpi-drive_manager. Running dietpi-drive_manager seems to hang when it is looking for the external drive (see attached pic). Also I tried power cycling the docking station, and then dietpi-drive_manager sees the drive a second time and shows it as “sdb1” instead of “sda1” and if you look in the attached picture it sees “sda1” as a network drive now.

Any ideas how I can remedy this? It seems like the external docking station is perhaps going to sleep which messes with how dietpi is viewing the drive. Rebooting RPI and power cycling the external docking station returns normal operation, but this is not ideal for use as a backup server.

I created a crontab entry that would more or less “poke” the drive to keep it from going to sleep

*/30 * * * *      root     /bin/touch   /dev/sda1 &>/dev/null

This way all it does is more or less does a touch, but doesn’t write anything to the drive keeping the drive from going to sleep
sure it’s a brute force nasty way to circumvent the drive going to sleep but it works

My drive is a 1TB MAC harddrive and it would disconnect as well…so I did “workaround” and it seems to be stable and working great without going to sleep…

Saw in /etc/hdparm.conf might be able to change it to a longer spindown time as well

Thanks Warhawk, I saw a similar solution on a different RPi site. I’m going to try your suggestion this next week. I also saw some things about hdparm. I’m unsure about this. It seems like a good idea to let the hard drive spin down to help it last longer, but it seems to have a negative effect with a RPi, not being able to wake it back up properly. I will let you know how it turns out. Thanks for your response and sharing your positive experience with the solution.