Wake up SMB drives before KODI starts


Hi there !
I’m having an issue where my TV Shows sometimes lose the scanned / TVDB info.
In some cases I’m also getting “invalid argument” when I try to browse the SMB drive via “Files” on KODI.
Anyway, I suspect that the problem might be related to the fact that the hard disk drive I have set up via SMB on KODI a few times gets to sleep mode after some time of inactivity. I’ve read that somewhere for that specific HD model.

On Windows 10 I don’t remember getting this issue, nor in Android.
However, to avoid this happening in the future, on windows I have created a mapsmbdrives.bat file with this code:

dir \ARCHERCLOUD\volume(sdb1)\Video\TV Series >nul
dir \ARCHERCLOUD\volume(sda1)\Video\Movies >nul

and I have placed it within the C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder.
So every time I start Windows, this is supposed to wake up my SMB drives so that they will be ready before / when I launch Kodi.

Now, I want to do something similar with CoreElec.
I have enabled “kodi start after network becomes active” with the default 10 seconds value within the CoreElec settings, but I don’t know if this can really help.

So, I’d also like to create a similar file (maybe “autostart.sh” ? ) that would act like that “mapsmbdrives.bat” on windows, by calling the hard drives with a command that would “wake” them up before KODI tries to access them.

Is this possible ?
Thanks in advance !


To add to the above post of mine, let me clarify that the two hard disk drives I use as SMB shares are plugged via a powered USB hub on my router’s USB 2.0 port. Both disks are 2,5’’ (USB powered). One of them (the one with the TV Shows) has the issue with the sleep mode.

Also, here are some things I’ve done or tried to do. Thing is that I’m not sure at all these are really helping my case, because they have to do with the network being available / ready, and not with waking up the SMB shares / drives from sleep (at least the one which seems to be the problematic that gets to sleep mode)

  1. I have enabled “Wait for network before starting Kodi” within the CoreElec settings, and I have increased the maximum wait time to 20 seconds.

  2. I have installed the “Advance Wake On Lan” Kodi add-on. On the “Basic Settings” tab I have typed my router’s MAC address and the IP it has. On the “Autostart” tab I have enabled “Activate Wake on launch” and “Activate wake after standby”. The problem here is that at the IP field you cannot add the smb share(s) you have. So this also seems to work only for the router, a server or a NAS, etc, and not for specific SMB shares.

  3. Within the Kodi Settings -> System -> Power Saving, I have tried to enable “Try to wake up remote servers on access”, but when I do so, it searches for the router’s MAC address and it fails, so I’m getting an error saying: “MAC Discovery - Failed for Archercloud”. I tried to fix this, by creating a ‘wakeonlan.xml’ with this content and placing it within the userdata folder (taken from here https://kodi.wiki/index.php?title=Wake_on_lan ):


where XX… is the Mac address of my router, but that did not help, and I was still getting the same error (“MAC Discovery - Failed for Archercloud”). Archercloud is the name my router assigns to the Network/Media Server it creates. Trying this on my Windows PC with Kodi 18.1 finds “Archecloud” and it does not “fail”. That’s weird. Both my TV box and my Windows PC are on the same network.

Now, as a newbie on these things, I have no idea if the above settings could help in my case.

Furthermore, I’ve searched the forums, and I have found some similar issues on this topic:

@vpeter has provided this code, that If I’m getting it right, delays starting kodi until a specific path exists.

So maybe using this code or something similar and replacing the path /var/media/USBHDD/recordings with something that refers to my problematic SMB share ( \ARCHERCLOUD\volume(sdb1)\Video\TV Series ) could work ?


I had a situation somewhat similar where I used a cron job to touch a hidden file every 6min as my drives had a 10min period before they would spin down. 6min was the closest and largest multiple I could get with cron.
You might be able to do something like that, and only set it during hours when you plan to watch tv. That way you might not have to give up all your power savings from spinning down the drives during off hours.


Thanks for the feedback.
I suppose a cron job (maybe just an ls command, or something like that every few minutes) for the specific drive would probably keep it awake, and this would be running only when my CoreElec tv box is on, so I wouldn’t have to worry that much about power saving, right ?
The problem here is that my Linux knowledge is limited (close to …non-existent), so I don’t even know where to start, how to create the cron job / script, where to put the code, and all that.


You would need to ssh into the device. Use crontab -e command.

You can use something like this crontab generate to get the format right if you are unsure.

Here is an example of someone using touch to keep a drive awake.

Google is your friend too.


Thank you. Much appreciated.
I will study these.