Using Synology NFS share to use with XBian

I struggled a bit to have a Synology NFS share to work with my XBian. So I thought I would share how I finaly handled this. In the first place, I managed to see my Synology NFS server within XBian, see the exported filesystem but could not browse them ! And in the end, it appears to be quite simple…

By the way, I am using DSM 5.x with a DS411.

You need to enable NFS service in Control panel

2014-04-06 12_33_07-SynoHomeServer

 

Then, edit the Shared Folder you want to shared using NFS, go to NFS permission and create a new rule.

2014-04-06 12_33_55-SynoHomeServer

  • set hostname to your XBian IP (here I used * so any host can access it)
  • set priviledge to Read or Read/Write
  • Select “Map all users to admin” as Squash option
  • Tick both check box, “Enable Asynchronous” & “Allow connection from non priviledged ports”

2014-04-06 12_34_15-SynoHomeServer

And that should be it ! Now I can browse the NFS share from within XBian.

 

Raspberry Pi has a new friend : ZiBASE Mini

Zodianet is a french startup which sells a home automation box : ZiBASE. They just released software running on ZiBASE for the Raspberry Pi : ZiBASE Mini. It is available as an SD card image or as a debian package.

zibase_mini_500

(image from www.zodianet.com)

There is a (not so) basic free version which is working with ZWave or enocean usb dongles. You will have a pay a licence for advance home automation (video streaming, data historization, scenarios…)

It is a nice way to start as software is free and Pi is cheap ! And it is known to work on CubieBoard also !

I’ll try it ! Downloading…

NFS root partition for Raspberry Pi

UPDATED on 12/04/2015 : added a way to get the offset and added -t ext4 option in mount command.

As stated in Raspberry Pi & SD card reliability, I had a try at using an NFS share as the root file system for one of my Raspberry Pi.

There is quite a lot of information on the subject on the net. But here is what I did.

Creating an NFS share

I own a Synology NAS. So I just created a shared folder and give permission to my Pi’s IP address. That is quite easy.

  • First enable NFS sharing if it is not already the case. Go to Control Panel > Win/Mac/NFS > NFS Service, tick Enable NFS and then apply
  • Then create an NFS share
    • Go to Control Panel > Shared Folders.
    • Create a new shared folder called piroot for instance
    • Click on Priviledges > NFS priviledges
    • Click create to add you Pi IP address (or a range if you prefer)

Copying proper files

Then, connect to you NAS using ssh for instance. Now you should have a new folder called /volume1/piroot on your NAS (/volume1 may be different on yours if you have several volumes.

I copied over an img file from raspberry.org and mounted the root fs included in the img file as a standard fs.

Took me a while to understand how to do it… To get the offset, you can use the command “file” but it is not available on the Synology. So I used Cygwin version of it on my Windows machine :

The offset to look at is the start sector of the second partition : 122880. And you need to multiply it by 512 (size of a sector in bytes) which gives 62914560. The other interesting stuff is partition ID : 0x83 which means ext4, thus the option -t ext4 in the following command.

Now, you just need to copy the files from the img file to your new NFS share, taking care of preserving permissions (-p option) !

Modifying fstab

You need to modify /etc/fstab on the Pi to remove the root fs entry. You will tell the kernel where is the root fs on its command line. If you keep this entry, Pi will not fully boot and it will complain about no being able to run fsck !

Preparing the SD card

Now we got our NFS share loaded with root fs files. Let’s configure the Pi boot. After dumping the raspbian OS to an SD card (I am on Windows so I use Win32DiskImager to to do that.) You then need to modify the cmdline.txt at the root of the SD card. Mine look like that :

Note that I removed all references to serial port which is by default used for connecting a debug console.

I did this because I need it for other stuff (Pi will be used for an emoncms server.) This is not mandatory for NFS to work.

The following entries are mandatory :

  • root=/dev/nfs : tells the Pi that the root fs will be on NFS
  • nfsroot=ip:/whatever/dir,udp,vers=3 tells Pi where is the root fs to be mounted
  • ip=dhcp : startup IP stack because you need it for NFS (I use DHCP but you could used a fixed IP.) If using a local fs, fs is mounted prior starting up the IP stack.
  • rootfstype=nfs : tells that the fs type is nfs

PXE…

By the way, no, you just can’t use PXE boot. The Pi doesn’t support it. The ONLY viable boot device is the SD card.

References

Here is a list of links that point to sources I used :

Raspberry Pi & SD card reliability

As described in a previous post, I use a Raspberry Pi as an emoncms server. And as it seems to occur for quite a number of users, SD card eventually gets corrupted after a week or so and Pi would crash and never reboots until I re-installed the OS.

First thing that came to mind was : “ok… the only thing that is quite write intensive is the mySQL database…” so I moved it to my Synology NAS. Now, emoncms barely writes anything onto the SD card. Did not last much longer…

So my second thought was “ok… SD card is not good enough, lets try another one…” My Pi worked for a while… a month or so… and finally crashed.

I came to the conclusion that I could not use a Pi for a reliable 24×7 system, and more specifically my emoncms setup… until I stumbled across this blog post : Rock-solid RFM2Pi gateway solution. The idea is quite simple but clever : set the file system as read only, using this version of Raspbian : IPE. But… hey… (almost) any apps needs some place to write to… Even if, in my case, I already setup an external database, apache probably won’t work on a read only file system out of the box. And worse, emoncms code probably writes some stuff on the file system (like traces or logs.)

So I thought I could mount the root file system from an NFS share that I created on my NAS. I will then have R/W capability on root file system but a read only SD card. I also had a look at iSCSI instead of NFS… but it way more complex and probably an overkill for a Raspberry Pi.

Stay tuned… I will try that soon !