# Integrating timedatectl//systemd-timesyncd with readonly root file system

**URL:** <https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323>\
**Category:** General Discussions\
**Tags:** yocto, raspberrypi-cm3, systemd, warrior\
**Created:** [August 17, 2020, 8:38pm UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323 "2020-08-17T20:38:53Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![thesillywhat](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thesillywhat](https://hub.mender.io/u/thesillywhat)\
**Post date:** [October 25, 2022, 9:53pm UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323/21 "2022-10-25T21:53:12Z")

</div>

Are you able to set different timezone using mount-copybind?

---

<div class="post-metadata">

**Author:** ![guillaumekh](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/guillaumekh/32/607_2.png) [@guillaumekh](https://hub.mender.io/u/guillaumekh)\
**Post date:** [April 24, 2023, 11:01am UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323/22 "2023-04-24T11:01:37Z")

</div>

Apologies for the necropost but this seems worth reopening.

@TheYoctoJester @thesillywhat @vssaran @SLIP76  
Were you trying to persist changes /etc/localtime to a RW partition, or were you OK with changes being written to a volatile overlay/partition and subsequently lost on reboots?

I’m asking because AFAICT binding /etc/localtime to a persistent partition is not a workable solution.

`timedated` does “[atomic writes](https://github.com/systemd/systemd/blob/f997f91d7dcf4fe2c8ff4e73274e045e15ec71ea/src/timedate/timedated.c#L326)” where the the symlink is created with a temp name, then moved to /etc/localtime with a C `rename()`. If attempted over a bindmounted `/etc/localtime`, this fails with a “resource busy” error

Generally speaking and AFAICT, a symlink cannot be created at a bind mounted path. And `mount-copybind` cannot overcome that.

My hunch is everyone here who reported getting this working was either:

- fine with TZ being lost on reboots and/or system updates
- fine with bindmounting the whole /etc directory
- fine with patching systemd/timedated to write the symlink to another location
- did not use systemd/timedated
- or built some service to keep /etc/localtime in sync with a copy located on a writeable path

If I’m mistaken, I’d love to see some actual code!

In my case, I have reached a point where I think I’ll leave the whole system in Universal time, and manage timezone at the application layer. Less moving parts and complexity to manage.

---

<div class="post-metadata">

**Author:** ![thesillywhat](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thesillywhat](https://hub.mender.io/u/thesillywhat)\
**Post date:** [April 24, 2023, 12:45pm UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323/23 "2023-04-24T12:45:57Z")

</div>

It depends on what your application is trying to do.

My application could not be on UTC. For me it was less work.  
So whatever helps you achieve it. Mine works okay for my application.

---

<div class="post-metadata">

**Author:** ![guillaumekh](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/guillaumekh/32/607_2.png) [@guillaumekh](https://hub.mender.io/u/guillaumekh)\
**Post date:** [April 24, 2023, 1:10pm UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323/24 "2023-04-24T13:10:32Z")

</div>

> > In my case, I have reached a point where I think I’ll leave the whole system in Universal time, and manage timezone at the application layer. Less moving parts and complexity to manage.
> 
> It depends on what your application is trying to do.  
> My application could not be on UTC. For me it was less work.  
> So whatever helps you achieve it. Mine works okay for my application.

FWIW, our application also needs to be timezone-aware. We just probably don’t need _the rest of the system_ to be timezone-aware.

In this case, it means we’ll probably end up writing the TZ information to a file on a persistent partition, and use that as a sytemd [EnvironmentFile](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=) so the TZ env var is used by our [app](https://nodejs.org/api/cli.html#tz).

Anyway, I’m still curious to know if anyone here did manage to get timedated working with a /etc/localtime bind mounted to a persistent partition.

---

<div class="post-metadata">

**Author:** ![thesillywhat](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thesillywhat](https://hub.mender.io/u/thesillywhat)\
**Post date:** [April 24, 2023, 1:27pm UTC](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323/25 "2023-04-24T13:27:20Z")

</div>

I didn’t and from what I have gathered, Systemd isn’t to keen on that. I had a big discussion with lennart pottering who not only rejected my patch but failed to provide me with a better solution.

And I didn’t tell him to do the work. I was willing to do the work and put in testing time.  
But yes, if anyone has better solution. I am open to ideas.

[Previous page](https://hub.mender.io/t/integrating-timedatectl-systemd-timesyncd-with-readonly-root-file-system/2323.md?page=1)
