2011-12-30, 12:29
This will only work for linux. I've only used Ubuntu but it should work on other distros.
If like me you use your HTPC for other tasks (watching live tv, games, browsing etc) then you probably don't want it waking your server/NAS on startup or resume. I have managed to get a working solution where the server/NAS is woken only when playback of a file on the server is requested (or if you 'update library'). No source code changes or compiling needed.
What you need to do is mount your remote shares using AutoFS, and point xbmc at the local mounted location on you HTPC.
Eg, i have a share located at \\SERVERIP\DATA1 which i mount to /mnt/DATA1.
I've had much better luck with smb rather than nfs, not sure why as both should work as far as i can tell.
First, installl AutoFS and etherwake:
I'm not going to go into AutoFS and its settings (i don't know most of them for a start), you can read up on it yourself.
My /etc/auto.master file has 1 uncommented line in it:
Then you need to create a new file /etc/auto.server. Hopefully it is fairly self-explanatory, but just ask if it isn't.
(replace SERVERIP and SERVERMAC with values for your system. Also, you may have to tinker with the sleep value)
Make the file executable:
So now whenever you (or xbmc) try to access /mnt/<share_name> on your local system autofs will kick in and call that /etc/auto.server file. That will ping the server and WOL it if it isn't on. Then autofs mounts the filesystem once the server is up.
Check /var/log/syslog or /var/log/messages (distro/version dependent i think) to see the logger outputs from the script.
Hopefully this will be useful to someone
If like me you use your HTPC for other tasks (watching live tv, games, browsing etc) then you probably don't want it waking your server/NAS on startup or resume. I have managed to get a working solution where the server/NAS is woken only when playback of a file on the server is requested (or if you 'update library'). No source code changes or compiling needed.
What you need to do is mount your remote shares using AutoFS, and point xbmc at the local mounted location on you HTPC.
Eg, i have a share located at \\SERVERIP\DATA1 which i mount to /mnt/DATA1.
I've had much better luck with smb rather than nfs, not sure why as both should work as far as i can tell.
First, installl AutoFS and etherwake:
Code:
sudo apt-get install autofs etherwake
I'm not going to go into AutoFS and its settings (i don't know most of them for a start), you can read up on it yourself.
My /etc/auto.master file has 1 uncommented line in it:
Code:
/mnt /etc/auto.server --timeout=60 --ghost
Then you need to create a new file /etc/auto.server. Hopefully it is fairly self-explanatory, but just ask if it isn't.
Code:
#!/bin/sh
#ping server ip in case its already up
ping -c 1 -w 1 -q SERVERIP > /dev/null
status=$?
logger "AUTOFS: Attempting to mount $1 filesystem from SERVERIP"
logger "AUTOFS: Result from ping - $status"
if [ $status -ne 0 ]
then
logger "AUTOFS: Host is not up. Sending wake-on-lan"
/usr/sbin/etherwake SERVERMAC
logger "AUTOFS: Sleeping for 5 seconds to allow host to wake"
sleep 5
fi
logger "AUTOFS: Re-pinging host"
ping -c 1 -w 1 -q SERVERIP > /dev/null
status=$?
logger "AUTOFS: Result - $status"
if [ $status -eq 0 ]
then
logger "AUTOFS: Mounting $1 filesystem"
#echo out autofs settings. Mount $1 share. $1 is passed in by autofs
/bin/echo -n "-fstype=smbfs,rw,username=user,password=password ://SERVERIP/$1"
else
logger "AUTOFS: Still no ping result from host"
Make the file executable:
Code:
sudo chmod +x /etc/auto.server
So now whenever you (or xbmc) try to access /mnt/<share_name> on your local system autofs will kick in and call that /etc/auto.server file. That will ping the server and WOL it if it isn't on. Then autofs mounts the filesystem once the server is up.
Check /var/log/syslog or /var/log/messages (distro/version dependent i think) to see the logger outputs from the script.
Hopefully this will be useful to someone