Gentoo timezone configuration: OpenRC /etc/timezone vs systemd timedatectl transition
0 reputation · 25 Jul 2024, 05:54 UTC
0 reputation · 25 Jul 2024, 05:54 UTC
Gentoo supports both OpenRC and systemd profiles, each with a distinct mechanism for selecting the system time zone. On OpenRC the active zone is traditionally recorded in /etc/timezone or via a symlink at /etc/localtime pointing into /usr/share/zoneinfo. On systemd the same symlink is managed exclusively through timedatectl set-timezone, and /etc/timezone is not consulted.
When a system is migrated from an OpenRC profile to a systemd profile — or when both toolchains are present during a staged transition — administrators may inadvertently edit /etc/timezone while timedatectl maintains a different symlink target. The resulting inconsistent state can cause services started under different supervisors to observe different zone offsets.
A second boundary concerns the hardware clock mode. OpenRC reads clock= from /etc/conf.d/hwclock (UTC or local), whereas systemd uses timedatectl set-local-rtc. Dual-boot configurations with Windows typically require local RTC, but the setting must be applied through the active init system's interface to avoid a mismatch at boot.
What is the recommended procedure to reconcile /etc/timezone and /etc/localtime when switching profiles? How should the hardware clock mode be synchronized across the transition? Does sys-libs/timezone-data provide any migration hooks or documentation for this boundary?
31775 reputation · 25 Jul 2024, 12:39 UTC
Confirmed fact: On OpenRC the zone is read from /etc/timezone and the symlink /etc/localtime is updated accordingly; on systemd the zone is managed solely by timedatectl and /etc/timezone is ignored.
Determine the desired zone (e.g., Europe/Paris).
If systemd is the active init, run timedatectl set-timezone Europe/Paris. This updates the timedatectl database and rewrites /etc/localtime as a symlink to the appropriate zoneinfo file.
Verify: timedatectl show | grep TimeZone and ls -l /etc/localtime.
If the system may still boot under OpenRC, ensure /etc/timezone contains the same zone name: echo \"Europe/Paris\" > /etc/timezone. If you rely solely on systemd, you may leave the file empty; systemd will ignore it.
Confirm that /etc/localtime remains a symlink, not a plain file.
Confirmed fact: OpenRC reads clock= from /etc/conf.d/hwclock; systemd uses timedatectl set-local-rtc. A mismatch causes the system clock to jump at boot.
Choose the mode: UTC (clock=\"UTC\") or local (clock=\"local\").
Apply via the active init system:
/etc/conf.d/hwclock and set clock=\"UTC\" or clock=\"local\".timedatectl set-local-rtc 0 for UTC or timedatectl set-local-rtc 1 for local RTC.If the other init system might still be used, mirror the setting in its configuration file (e.g., set clock=\"UTC\" in /etc/conf.d/hwclock even when systemd is current).
Verify after reboot: hwclock --show and date should agree within a second.
sys-libs/timezone-data provides only the zoneinfo files; it offers no migration hooks or automated documentation for this boundary. All steps must be performed manually or via admin‑written scripts.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.