My Buffalo NAS (Linkstation Live) is quite old but still doing its job. Recently I switched to a new version of Linux Mint on one of my laptops. I have a need for copying large files from my laptop to the NAS, mostly captured movies since the laptop has a firewire port. Nearly all Linux distributions provide SMB/CIFS support, in this case I needed a SMB/CIFS client to be able to mount the NAS, since the NAS exports a SMB/CIFS service interface.
The first problem is that Buffalo NAS goes down very quickly into sleep mode and waking it up from sleep mode takes a couple of minutes. The windows software from Buffalo keeps the NAS alive by using Wake-On-Lan i.e. sending ‘magic’ packets keeping it awake.
The NAS needs wake-on-lan packets every 30 seconds, so I made a short python script calling wake-on-lan regularly in a while-loop:
A call to the script was then added to /etc/rc.local which is run automatically during startup. The line in rc.local looks like:
python /usr/local/bin/wakeupnas.py &
The last character ‘&’ is important since it makes the script spawn off as a separate process. Next step was to do the actually mounting to the filesystem. First I tried to do it using the normal mount command:
> sudo mount -t cifs //nas/dir /mylaptop/mountpoint
This of course worked, so I moved over to configure the mount daemon by configuring the actually mounting in /etc/fstab. Next time I started my laptop, I went to the mountpoint happily and expected all files to appear from the NAS – but nada, nothing! The problem was that my laptop tries to do the mounting before the NAS is ready (the NAS takes roughly 3 minutes to boot). I needed another solution and turned to AutoFS which is automounting. By using automounting, the directory is mounted at the same time you try to acccess it. A nice side-effect is if quoting from help.ubuntu – “automounting NFS/Samba shares conserves bandwidth and offers better overall performance compared to static mounts via fstab.“
First of all I checked that I had AutoFS installed including the kernel support, but I suppose this is default on Linux Mint. Next I performed the following two steps:
1. Add user credentials (i.e. usernamne and password) in a file and put it into /etc/creds/. I also had to add a static hostname in my router to make it work.
2. Secondly, I had to add the following row to /etc/auto.master:
/cifs /etc/auto.smb --timeout 300
In short this line means “if accessing the directory /cifs/ run the script auto.smb which will look into /etc/creds/ and automount all exported directories of the NAS”
Made a quick reboot of my laptop and change directory into /cifs/. VIOLA! There they were, all my directories of the NAS!