Domoticz running from NFS share (synology)

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Domoticz running from NFS share (synology)

Post by pvm »

Hi all,

Introduction
I sometimes have issues with a corrupted sd card (in raspberry PI). Occasionally after an update of domoticz the machine does not restart. I do create an image of the SD card on daily basis, so I'm always up-and running quite fast. But it takes an hour or so...
Yesterdat I started installing a Domoticz slave PI system and do not want the same issues... so googled on getting the pi running from a network share and found info in this location


For my own reference ;) and possibly for other domoticz users I've created a description. Actually... the system still boots from SD, but all files are stored on NFS share. So you cannot remove the SD card.

HowTo setup NFS share on Synology nas
Open the DSM interface as administrator
  • Open the control panel
  • Open 'Shared folder'
  • Click create button
  • Fill share name and description, for this example I use 'PISlaveTest'
  • In the next window you can give rights to nas users (for samba/windows network access)
  • Click NFS permissions
  • Click create
  • Fill the hostname/IP with your raspberries IP or your network range, for example 192.168.1.* (to give all devices in your local network access)
  • Ready, NFS share is available now (also as samba/windows network share)
HowTo setup PI
Start with a running Domoticz system. MAKE A BACKUP(!), you can make your PI unbootable (use something like win32diskimager on a windows system)
Mount (connect to) the NFS share
  • Enable RCPBind: "sudo update-rc.d rpcbind enable"
  • Mount the NFS share: "sudo mount 192.168.1.2:/volume1/PISlaveTest /mnt" (where 192.168.1.2 is the IP of my NAS, 'volume1' is the disk volume in my nas and 'PISlaveTest' is the share name
Copy all files to the share (this will take quite some time)
  • sudo cp -axv /. /mnt/.
  • sudo cp -axv /dev/. /mnt/dev/.
Change the boot settings to make use of the NFS share
  • sudo nano /mnt/etc/fstab
  • Delete the line which mounts /dev/mmcblk0p2 on / or comment it out (#).
  • sudo nano /boot/cmdline.txt and copy the following:
  • dwc_otg.lpm_enable=0 console=tty1 root=/dev/nfs rootfstype=nfs elevator=deadline rootwait nfsroot=192.168.1.2:/volume1/PISlaveTest,udp,vers=3 smsc95xx.turbo_mode=N ip=192.168.1.7:192.168.1.2:192.168.1.1:255.255.255.0:PISlaveTest:eth0:off
    (where .7 is the IP of domoticz (using static IP, as already configured before on PI, this might totally replace that config), .2 is the NAS, .1 is the gateway)
Now you should be able to reboot your system and run from the NFS share (for booting the SD card is still required)

Move your swap partition to NFS share
First clean the old swap
  • sudo apt-get remove --purge dphys-swapfile
  • sudo rm /var/swap
  • sudo rm /etc/init.d/dphys-swapfile
  • sudo update-rc.d dphys-swapfile remove
Now create a new swap file and setup the loop device, then activate the new swap
  • the first step will create an 1gb file, will take some time...
  • sudo dd if=/dev/zero of=/var/swap bs=1M count=1024
  • sudo losetup /dev/loop0 /var/swap
  • sudo mkswap /dev/loop0
  • sudo swapon /dev/loop0
This has created a 1GB swap file in the /var directory. Check your new swap with the command free -m. This should tell you how much swap space is available.

To make these changes permanent, edit the /etc/rc.local file and add the following before exit 0 .
echo "Setting up loopy/var/swap.."
sleep 2
losetup /dev/loop0 /var/swap
mkswap /dev/loop0
swapon /dev/loop0

There you have it, your network swap file will be active on boot now.

Here’s a couple of tweaks to system files to do some fine tuning. First, edit /etc/default/rcS and add 'ASYNCMOUNTNFS=no'.
Now edit /etc/sysctl.conf and add or change 'vm.min_free_kbytes = 16384' This will set aside 16MB of free RAM to prevent the risk of a kernel panic. You may set this value lower if you wish, but on a 512MB Pi it’s not a huge concern.

Good luck!

I will execute this setup in a few weeks when this system keeps running fine (it did for 24 hours now)
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Raspberry Piet
Posts: 158
Joined: Saturday 11 January 2014 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Domoticz running from NFS share (synology)

Post by Raspberry Piet »

I never had the issue of a corrupted sd card. (but i read many people have this problem)
To prevent this would also happen to me i moved the filesystem to an usb stick, i used this tutorial wich describes about almost the same steps you took.
I prefer to use the usb mount instead of the nfs mount. (when your diskstation isn't available in your network, your raspberry pi has a problem)
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Domoticz running from NFS share (synology)

Post by pvm »

Agree, NFS has one small advantage: direct access to the disk using network
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz running from NFS share (synology)

Post by Doudy »

Hello,

When I get the following command : sudo cp -axv /. /mnt/.
I have the following error message :
cp: impossible de préserver l'appartenance pour « /mnt/././lost+found »: Argument invalide « /./bin » -> « /mnt/././bin »

is it serious doctor ? ;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
gizmocuz
Posts: 3072
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Domoticz running from NFS share (synology)

Post by gizmocuz »

why not using berryboot and use iSCSI ? 100% from lan...
Quality outlives Quantity!
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz running from NFS share (synology)

Post by Doudy »

gizmocuz wrote:why not using berryboot and use iSCSI ? 100% from lan...
:?: :o :?:
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
gizmocuz
Posts: 3072
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Domoticz running from NFS share (synology)

Post by gizmocuz »

Doudy wrote:
gizmocuz wrote:why not using berryboot and use iSCSI ? 100% from lan...
:?: :o :?:
http://lmgtfy.com/?q=berryboot+iscsi
Quality outlives Quantity!
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz running from NFS share (synology)

Post by Doudy »

:idea: Intéressant :idea:
Merci
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: Domoticz running from NFS share (synology)

Post by Holland »

Well, almost then. You still need to load a preboot kernel and initramfs from SD. If you're a real geek you move all that to TFTP and be completely diskless.
Since recently it's possible to boot from ethernet (PXE); have a look over here; https://www.raspberrypi.org/blog/pi-3-b ... e-awesome/

Would like to do that in combi with Power over Ethernet. That would be perfect, then all the hassle with powersupplies is also history. Imagine that you then can power your Pi's via a managed switch. Nice!

Only problem is that a separate adapter is required for the Pi, since it's not able to work directly with PoE. A bit of an issue is that these adapters can be relative expense.

The Raspberry foundation finds the PXE development quite relevant, therefore I expect that the next Pi (Pi 4) will support PoE natively. Maybe better to wait for that.
Post Reply