2018-01-30

Power-fail safe configuration

My RPi HMI device must be more like embedded than the OS-driven system. The close use case is kiosk (a totally new English word for me, had to check a dictionary!)


What does it mean and what have I to do with it?
Justin Kulesza gives the description of the necessity, as well as a general approach to the solution. No need to repeat the story. Just note that the industrial "kiosk" must be even more robust. 
So, my steps, based on the Domoticz instructions.

Downloads: all of recommended, i.e. mount_overlay and saveoverlays-jessie scripts, then edit the shebang, attributes and moving the scripts to  /usr/local/bin and /etc/init.d respectively.

Backup files:
  • /boot/cmdline.txt
  • /etc/fstab
  • /var directory
Stop using swap

Move fake-hwclock.data file to /var/log/ and leave a link instead (I'm not sure I need it actually, but no harm). Said, it's used in saveoverlays service.

Install the fuse package.

Set up the saveoverlays service.

Add noswap fastboot ro at the end of the /boot/cmdline.txt

Update the /etc/fstab file. Mine is like this:

proc            /proc           proc    defaults          0       0
PARTUUID=6dfa64bb-01  /boot           vfat    ro          0       2
PARTUUID=6dfa64bb-02  /               ext4    ro,noatime  0       1
mount_overlay   /var            fuse    nofail,defaults,x-systemd.automount,x-systemd.requires=/var,x-systemd.device-timeout=10s 0 0
mount_overlay   /home           fuse    nofail,defaults,x-systemd.automount,x-systemd.requires=/home,x-systemd.device-timeout=10s 0 0
none            /tmp            tmpfs   defaults    0 0

Prepare the overlay directories
Only two of the services to be stopped were active in my case. Still, I've executed all commands. Then, /home and /var directories were propagated to form such a list: *_org, *_rw and *_stage

Mount /home and /var. Skip modifying the dominicz.sh service. Reboot.
Test with the mount command. I see the following:

/dev/mmcblk0p2 on / type ext4 (ro,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=470180k,nr_inodes=117545,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
ramdisk on /var_rw type tmpfs (rw,relatime)
ramdisk on /home_rw type tmpfs (rw,relatime)
overlay on /var type overlay (rw,relatime,lowerdir=/var_org,upperdir=/var_rw/upper,workdir=/var_rw/work)
overlay on /home type overlay (rw,relatime,lowerdir=/home_org,upperdir=/home_rw/upper,workdir=/home_rw/work)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=94956k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)

Satisfied, I check the updating of the system - OK!

So far, so good. I hope.












No comments:

Post a Comment