YIO-Remote/remote-os

Timezone is no longer persisted due to read-only root file system

zehnm opened this issue · 2 comments

zehnm commented

Description

After introducing the read-only root file system, the timezone can no longer be set with timedatectl set-timezone.

How to Reproduce

Steps to reproduce the behavior:

  1. Log in by ssh
  2. Set a new timezone, e.g.: timedatectl set-timezone UTC
  3. Reboot remote
  4. Check timezone with date: back to CEST

Expected behavior

Timezone can be set and is persisted during reboots.

Your Environment

  • Version used: latest master
  • Running on:
    • YIO Remote
    • Standalone Raspberry Pi

Additional context

The /etc file system overlay is only an in-memory overlay which is not persisted during reboots.

zehnm commented

My current understanding: timedatectl is a systemd utility, which requires /etc/localtime to be a symlink to the timezone information. The /etc/timezone file is mostly a "Debian thing". Setting a new timezone with timedatectl only sets a new symlink and leaves /etc/localtime untouched.
More information:

Options:

  • Use TZ environment variable
    • Easy for shell & system stuff
    • Awkward to integrate into app
# date
Tue Feb  2 18:00:51 CET 2021
# export TZ=UTC
# date
Tue Feb  2 17:01:04 UTC 2021
# export TZ=US/Hawaii
# date
Tue Feb  2 07:01:38 HST 2021
  • Just use UTC as system time and handle the timezone offset in the app.
    • Needs special handling whenever dealing with times
    • Logfiles and file timestamps will be UTC
  • Persist symlink so that timedatectl can be used. Options:
    • bind-mount doesn't seem possible
    • use a persistent overlay for /etc (as for /var). Easiest solution but /etc was intended to be read-only with special exceptions.
    • Individual files are synced between the in-memory overlay and the data folder.
zehnm commented

Setting the TZ variable in /opt/yio/app-launch.sh works fine. I think this is the easiest way to make the timezone user configurable with a read-only root filesystem and leaving systemd untouched.

  • Set system timezone to UTC
  • Store app timezone in user data file within the yio directory
  • Read the user data file in the app start up script
  • Write the user data file from within the initial setup / app configuration screen.

Alternatively a profile.d entry with a bind-mount could be used.