Saturday, 12 July 2014

WDLXTV net.mounts

As is often the case - if you have some elaborate complicated process to do something that should be easy, you probably haven’t read the documentation properly.

I use a net.mounts file in the /conf directory on my WDTV Live to mount an NFS share from my NAS on startup. It’s so simple, but I haven’t always done it this way. I did it the hard way for a long time.

Mounting this share is important. The WDTV Live is hooked up to a TV in my kid’s play room and the NAS’s NFS share offers some quality peace & quiet inducing content! (in moderation)

With such a high household priority I was happy to ssh to the WDTV, provide the required credentials then execute the command to mount the share - every time the device was reset or removed from the power source. This took about 6 months to get old. Six months longer than it should have taken:

$ ssh -lroot wdtv-host-ip
% xmount nas-host-ip:/kids-media/ NFSMedia nfs

This obviously fails the wife test. If I wasn’t home, there was no way I was going to talk her through anything beyond opening the on the mac.

To make it a little easier I decided to copy the mac’s public key to the ssh authed keys on the WDTV. Gee, so much easier (not really)

$ ssh -lroot wdtv-host-ip
% xmount nas-host-ip:/kids-media/ NFSMedia nfs

With passwordless ssh access I figured I would at least provide a simple one liner method for anyone to mount this bloody share when I wasn’t there!

$ echo "xmount nas-host-ip:/kids-media/ NFSMedia nfs" |ssh -lroot wdtv-host-ip /usr/bin/bash

“Hi sweetheart, Just open Terminal and type …. oh ok, I’ll do it when I get home”

How about I just wrap it up in a shell script, couldn’t be easier right? Of course it could - no-one other than someone that knows what a shell script it should have to execute one.

$ vi

echo "xmount nas-host-ip:/kids-media/ NFSMedia nfs" |ssh -lroot wdtv-host-ip /usr/bin/bash

$ ./

I know, how about I make it double clickable!

$ mv mount_nas_share_on_wd.command

Me: “OK, when the share folder isn’t showing up on the WD, just go to the mac and 2xclick on mount_nas_share_on_wd.command”

Wife: “Can’t it just show up automatically when the WD boots up?”

Me: “Yes, you’d think so wouldn’t you”

So I go back to the exact same web resource where I found the xmount command in the first place and there it was - net.mounts “it will mount network shares on boot”

So reading entire documentation beats cherry picking, in this case at least.