I have an external hard disk drive, formatted with ext4 and connected to my Pi 3B+ running Raspbian with Kernel 4.19.97-v7+. Every now and then, usually after about 12 hours, but sometimes a few days the hard disk drive is no longer mounted and no longer visible.
I have mounted it in the past by running
sudo fdisk -l to find the device and then running
sudo mount /dev/sda1 /mnt/external. The problem was that every now and then, the hard drive would not be at /dev/sda1 but would have moved to /dev/sdb1, then /dev/sdc1 and so on. To get around this, I got the UUID of the drive by running
sudo blkid and then added it to
/etc/fstab by adding the following line:
UUID=3eb6e277-0b3e-40d6-988a-d4200977f79f /mnt/external ext4 defaults 0 0
Now, this does mount the drive at startup but every now and then it is no longer mounted. If I go to /mnt/external there are no files. If I run
sudo fdisk -l, it is not listed. The only way I could find around this was to reboot.
Something that I have tried is adding the following jobs to my crontab. The intention here was to write on the hour and then delete at half past the hour. I thought that perhaps the hard drive was entering some power saving state. The files are being added and removed, right up until the disk disappears.
30 * * * * rm /mnt/external/keep-hdd-alive 0 */1 * * * touch /mnt/external/keep-hdd-alive
Does anyone know how I can make my hard drive stay mounted and available?