Random HDD Spin up after being idle

Hello Everyone! I have set up my first NC using the below configuration:
Hardware:
Raspberry pi 4
WD Red 1tb 2.5 HDD

Software:
On latest version of NCP, and have no additional packages (Besides hd-idle).

I have noticed that the HDD does not spin down on its own while not being in use after a couple of hours. So naturally I googled what was happening to try to fix this issue. I came across this site that said how to fix this issue. With my configuration hdparm and sdparm does not work, but hd-idle will spin down the hdd after X amount of time. The issue now is that it will randomly spin back up a couple minutes later even though it is not in use. The googling continues.

I now find this site. Close to the bottom of the page they explain that they had a similar issue to me, which was caused by udisks. Then they explain how to fix the issue by editing a udisks file. Unfortunately NCP doesn’t use udisks (to my knowledge) , but it does use udisks2, which from my understanding udisks and udisks2 do very similar things.

Now I have had no luck trying to find additional information on how to fix this issue which I am assuming is from udisks2.

Any help/ insight would be greatly appreciated!

Did you set up cron jobs? They often run every 15 minutes (not sure how this is configured in NCP), you might want to change that. Furthermore, you could check your webserver log if there are clients connecting to the server on a regular basis.

1 Like

NCP’s crontab for www-data

sudo -u www-data crontab -l
*/15 * * * * php -f /var/www/nextcloud/cron.php

Maybe try enable nc-ramlog?
and possibly post output of ncp-report via pastebin or similar?

Hi All

I have the same issue. I’ve a RP4 built with the latest Nextcloudpi image and using a WD 4Gb portable HDD. The hdd doesn’t go to standby, ever. Configuring RAM logs didn’t help.

These hdds use their own firmware for power management so the problem isn’t about Linux configuration. And I’ve disabled any obvious NC actions that’ll cause hdd access. eg. check for manually added data files. Something else is accessing the drive and preventing standby.

I’ve started to try and work it out. As this is a new build with no user data I was able to move the swap file, nc database and nc data one at a time to the sd card. Only after finally moving the nc data the hdd goes to sleep. So I guess this narrows it down a bit.

At the moment I’m assuming something in /var/www/nextcloud/cron.php is causing the hdd access. Tonight’s job is to have a look. Any tips on doing this would be gratefully received.

Thanks.

Just change the timing of the cronjob. When the cronjob is not running, it can’t send out notifications. Check out what suits you most (e.g. run it once an hour during the day and only a single time at during the night).

I’ll move my nc data back to the hdd and change the cronjob to run infrequently to see if this is what’s triggering the hdd accesses.

Looking at nextcloud/cron.php I didn’t really get that far. I seems to pull in a “joblist” but I couldn’t work out the contents. Before disabling or reducing the cronjob frequency permanently of this I’d like to better understand the impact. Which logs would show me this ?

Thanks

So it’s definitely cron.php triggering the hdd access. To get an idea of what’s it doing I removed the www-data crontab cron.php entry to stop it running.

Then enabled debug log mode by adding the line:

‘loglevel’ => 0 to /var/www/nextcloud/config/config.php

Then opened an admin page in a browser and selected logging.

Then I manually triggered crong.php with:

sudo -u www-data php -f /var/www/nextcloud/cron.php

In the logs I then saw cron.php pulling in the jobs backlog, things like:

\Files_Sharing\DeleteOrphanedSharesJob
\Files_Versions\BackgroundJob\ExpireVersions
\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob
\Files_Trashbin\BackgroundJob\ExpireTrash
\BackgroundJob\EmailNotification
\Files\BackgroundJob\CleanupFileLocks
\Files\BackgroundJob\DeleteOrphanedItems
\ScanFiles

I assume other tasks will be added to the list from time to time dependant on their required frequency.

I’m going to try running cron.php twice a day. At 6:45 and 19:12, the theory being that it’ll be reasonably up to date when I’m likely to use it, during the day and in the evening. I should mention apart from auto uploads from the household phones I’m only likely to use Nextcloud a couple of times a week. The achieve this I edited the www-data crontab to have the follow entries:

45 6 * * * php -f /var/www/nextcloud/cron.php
15 19 * * * php -f /var/www/nextcloud/cron.php

If don’t get any issues I’m thinking longer term I’ll reduce it to one run around lunchtime.

I should note I still have swap and the database on my SD card.

I’d welcome thoughts on my observations and plans.

Cheers

1 Like

While searching to prevent Nextcloud from spinning up my disks, I came across this interesting topic.
I took another approach by only running the cron job if the disks are spinning anyway.
I’m using another setup, but for others stumbling across this in search to solve this problem, my post here might just be useful enough to fix it themselves.

2 Likes