[How To] Auto Update your library from NAS at startup

Volumio cannot automatically update your library from a NAS due to limmitations of the inotify in linux which does not work on network mounted devices.

So with the use of cron we can get it to update on startup, not as nice as dynamically updating your library but it is what it is.
It is not just as simple as running an update command at startup as if the network is not up or the NAS has not yet been mounted you will end up with an empty database.
So we also have to detect that the NAS has been mounted before running the update.

But First things first Backup or use a spare SD card just in case

SSH into Volumio

Install cron

sudo apt update
sudo apt install cron

Edit cron
crontab -e
This should open a nano edit window with a load of commented text.
scroll to the bottom and add the line…

@reboot ./start.sh

write out(ctrl o) and exit (ctrl x)

That has just told cron that at after a reboot to run a script called start.sh

Now we make a script to detect the mount called start.sh
First we need to find out what your mountpoint is with…
findmnt -l
you will get a list of all the mounts, now find your NAS

this is mine…

/mnt/NAS/Server //

/mnt/NAS/Server You will need this part for your script ( yours will be different)

Now make the script

nano start.sh
which will open an empty nano edit window then paste in the following, but remember to change your --mountpoint name (2nd line) to the one you found earlier

#! /bin/bash
if findmnt --mountpoint /mnt/NAS/Server;
        sleep 5
        mpc update --wait NAS/
        sleep 2
exec bash "$0" "$@"


write out(ctrl o) and exit (ctrl x)

Make the script executable
chmod +x start.sh

Thats it, all going well every time you turn on Volumio will update your library from your NAS

1 Like

Recently I have found that if Volumio is installed on larger / faster sd cards then the update doesn’t always happen.

This seems to be resolved by increasing the wait time just before the update command to 5 seconds.