Vero 4k USB HDD unmount


I really need a way to stop the USB HDD during the night from being used by osmc.
It starts working from time to time and the noise is not acceptable during the night.

I tried to use the following cron job for the purpose:

10 0 * * * udisks --unmount /dev/sda1
10 8 * * * udisks --mount /dev/sda1 /media/WDMyBook

Unfortunately I cannot count on it doing the job, since it happens sometimes that some process is using the HDD and udisks refuses to unmount it.

Could you please advise a reliable way to prevent the usb HDD from being activated through the night, apart from shutting down Vero 4k or manually unmounting each night?


You’ll need to experient here to see if it doesn’t have any untoward effects but you could simply try to run the unmount every ‘n’ minutes from midnight to 08:00. Using a 5-minute value, for example, your cron entry would be:

*/5 0-7 * * * /usr/bin/udisks --unmount /dev/sda1 >/dev/null 2>&1

I’ve sent any output to /dev/null but you can write it to a log file if you wish.

Edit: Rookie error. :wink: Changed run hours from 0-8 to 0-7.

That seems a good idea. I’ll try, although I don’t really know which process keeps the HDD busy.
I thought it was samba… maybe I’ll add stop to samba as cron job too.
I’ll write back to share the result.

Actually it didn’t seem to work with your syntaxis for some reason… Cron is tricky.
Then I tried:

* * * * /usr/bin/udisks --unmount /dev/sda1 >/home/osmc/cronlog

It worked.


* 0-18 * * * /usr/bin/udisks --unmount /dev/sda1 >/home/osmc/cronlog

(it is 14h) It worked.

So I settled with:

* 0-7 * * * /usr/bin/udisks --unmount /dev/sda1 >/home/osmc/cronlog
* 8-9 * * * /usr/bin/udisks --mount /dev/sda1 /media/WDMyBook >/home/osmc/cronlog

I’ll check tonigh if it’ll work.
I just wonder why your syntax didn’t work… Seems OK to me (although I have virtually none experience with cron).

Thanks again for helping me!
I am sure some people will profit from this forum entry, as spinning of HDD all through the night is quite annoying.

The syntax for redirection to /dev/null looks ok to me. (It is ok.) Must be something else causing an issue.

A few points:

You might also want to send any error messages to your log file (using 2>&1).

Using >/home/osmc/cronlog will overwrite the file each time (each minute) it runs and you’ll lose all previous messages. For diagnostic purposes, better to use >>/home/osmc/cronlog until you’re sure it’s running as you want.

I don’t think you need to try mounting the disk for two hours. Unlike the unmount, once should normally be enough.

Yes, I’ll edit it.

Unfortunately it does not work :frowning:

It must be the time syntax - I have now:

* 23-7 * * * /usr/bin/udisks --unmount /dev/sda1 >/home/osmc/cronlog 2>&1 
10 8 * * * /usr/bin/udisks --mount /dev/sda1 /media/WDMyBook >/home/osmc/cronlog 2>&1

It didn’t unmount.
I did manually:

/usr/bin/udisks --unmount /dev/sda1 >/home/osmc/cronlog 2>&1

It unmounted. AND it overwrote the log line!
Where’s the problem?!

I think it must be the past midnight parameter.

I’ll try * 21,0-7 * * * now.

Write a shell script to run these commands
Have cron run the shell script

Mark the script as executable or use the full path to the interpreter

Thanks for the input, but how the shell script will change cron not wanting to execute a job with range past midnight?

Ah didn’t see that

Check your syntax and make sure you have a new line before the end of the crontab

Why not just stop mediacenter during that time as that would be the only process that would wake up your harddisk unless you have e.g. samba server installed

You mean kill kodi?
Or shut down Vero 4k?
I haven’t thought about the first, as it seems not an elegant way to do it.
As for the second, obviously it is not supposed by design and is hard and slow to start again.

sudo systemctl stop mediacenter
Why would this not be elegant? Better than just stealing the harddisk underneath.

I suppose I have to start it after with sudo systemctl start mediacenter?
It is an idea, thanks.
However cron will have problem with sudo.

Yes start will start it.
You don’t need sudo if you put it in main crontab and execute as root

I’ll consider this, thank you.
If it doesn’t work as it is now.
(I don’t see a problem with unmounting the disk as a more direct approach. After all if it is busy, it’ll refuse being unmounted.)

Well e.g. what would happen if you are successfully unmount it and Kodi tries to access it shortly afterwards

I don’t really know.
Won’t be able to?
From what I saw, if I try to access a movie and the drive is unmounted, Kodi just proposes to delete it from the library as it is not present anymore.
I should say, the HDD only contains media.

This is exactly the point why I suggest to shut down Kodi instead of just stealing it’s media files

@fzinken is right. You’ll need to shut down mediacenter and samba, since you mentioned in post #3 that samba is also running. Create the cron job to run under root using sudo crontab -e. The disks might then spin down automatically.