{"id":869,"date":"2019-12-02T23:27:06","date_gmt":"2019-12-02T21:27:06","guid":{"rendered":"http:\/\/raytec.org\/wordpress\/?p=869"},"modified":"2019-12-02T23:27:06","modified_gmt":"2019-12-02T21:27:06","slug":"systemd-and-how-to-a-adapt-for-read-only-nfs-for-raspberry-pis-thinclients","status":"publish","type":"post","link":"http:\/\/raytec.org\/wordpress\/2019\/12\/02\/systemd-and-how-to-a-adapt-for-read-only-nfs-for-raspberry-pis-thinclients\/","title":{"rendered":"Systemd &#8212; and how to a adapt for read-only NFS for Raspberry PIs Thinclients"},"content":{"rendered":"<p>Systemd is a powerful init-system for Unix; most of the Distros have moved away from sysv-based (System V, init calls scripts based on \/etc\/inittab and \/etc\/rc*.d). Notable forks of &#8222;traditional&#8220; (back-wards oriented?) distributions are Devuan (Debian without Systemd), funtoo (forked from Gentoo).<\/p>\n<p>Now systemd has many nice features such as fine-grained dependency-tracking and therefore concurrent, parallel startup of independent resources. Dependency may be one service depending on the other (feature-wise or time-wise) or even a provided resource (a device, a mount-point, a file within a mount-point).<br \/>\nWith all this flexibility comes power, and complexity.<\/p>\n<p>At HS-Esslingen, I maintain a computer pool with lots of Raspberry PIs: this I want to boot over the network, namely NFS, so that I don&#8217;t have to juggle with SD-cards being overwritten, being in a poor state and always out-of-sync. Students should be able to do anything on their respective RPI (like programming and loading a kernel module), yet be able to go back to reboot the well-tested and full-featured Raspbian provided to them centrally.<\/p>\n<p>Read-only NFS works very well (except for corner-cases such as Chromium requiring loads of dynamic libraries that need to be fetched single-file over NFS).<br \/>\nHowever, with every Raspbian update, there are changes that require adaptations: With Raspbian 10.2 being based on Debian Buster, there are several ones, one particular I want to highlight here:<br \/>\nThe Service <code>systemd_timesyncd<\/code> requires access to the file <code>\/var\/lib\/systemd\/timesync\/clock<\/code> &#8211;this directory therefore has to be read-writable. To do so, we need to mount an <code>overlay<\/code> on top of RAM-backed <code>tmpfs<\/code>.<br \/>\nThis is to be only, if we have the common case of student work on the RPIs, but should not be done, when we *want* to access and update files in <code>\/var\/lib<\/code>. Another directory made accessible locally using RAM-backed storage is <code>\/var\/cache<\/code>, e.g. to allow work with aptitude <code>apt search<\/code>.<\/p>\n<p>Previously, I had done this check, the creation of mount-point directories and the mounts themselves in one extra systemd service and hooking that into the systemd <code>local-fs.target<\/code>. This is <b>not<\/b> very elegant.<\/p>\n<p>A better way is to specify two mount-targets: <code>var-lib.mount<\/code> and <code>var-cache.mount<\/code>, which are very similar:<br \/>\n<code><br \/>\n[Unit]<br \/>\nDescription=Overlay FS for \/var\/lib<br \/>\nDocumentation=https:\/\/www.kernel.org\/doc\/Documentation\/filesystems\/overlayfs.txt<br \/>\nDocumentation=https:\/\/www.freedesktop.org\/wiki\/Software\/systemd\/APIFileSystems<br \/>\nWants=create_tmp_dirs.service<br \/>\nAfter=create_tmp_dirs.service<br \/>\nConditionPathIsMountPoint=\/var\/tmp<\/p>\n<p>[Mount]<br \/>\nWhat=overlay<br \/>\nWhere=\/var\/lib<br \/>\nOptions=lowerdir=\/var\/lib,upperdir=\/var\/tmp\/lib_upper,workdir=\/var\/tmp\/lib_work<br \/>\nType=overlay<br \/>\n<\/code><\/p>\n<p>Then, one may adapt <code>systemd-timesyncd.service<\/code> by replacing it into <code>\/etc\/systemd\/system<\/code>, adding just one line:<br \/>\n<code>RequiresMountsFor=\/var\/lib\/systemd\/timesync\/clock<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Systemd is a powerful init-system for Unix; most of the Distros have moved away from sysv-based (System V, init calls scripts based on \/etc\/inittab and \/etc\/rc*.d). Notable forks of &#8222;traditional&#8220; (back-wards oriented?) distributions are Devuan (Debian without Systemd), funtoo (forked &hellip; <a href=\"http:\/\/raytec.org\/wordpress\/2019\/12\/02\/systemd-and-how-to-a-adapt-for-read-only-nfs-for-raspberry-pis-thinclients\/\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-869","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/posts\/869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/comments?post=869"}],"version-history":[{"count":1,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/posts\/869\/revisions"}],"predecessor-version":[{"id":870,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/posts\/869\/revisions\/870"}],"wp:attachment":[{"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/media?parent=869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/categories?post=869"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/raytec.org\/wordpress\/wp-json\/wp\/v2\/tags?post=869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}