archinstall icon indicating copy to clipboard operation
archinstall copied to clipboard

Timezone is not being set correctly

Open l4zy0n3 opened this issue 4 years ago • 11 comments

Time is always set to UTC

We might need to create a forced symlink to /etc/localtime

Tested on tag v2.2.0

  1. Set the timezone eg: Asia/Kolkata
  2. chroot after installation, verify /etc/localtime, reboot and verify
  3. Timezone is set to UTC irrespective of choice at the installer prompt

l4zy0n3 avatar May 31 '21 03:05 l4zy0n3

Check, I remember I used to unlink the target (/etc/localtime) before setting it, that might have gotten lost somewhere.

Torxed avatar May 31 '21 10:05 Torxed

Check, I remember I used to unlink the target (/etc/localtime) before setting it, that might have gotten lost somewhere.

Update - unlink is present, it's still not working, tried adding the force flag in ln, did not work

l4zy0n3 avatar Jun 01 '21 06:06 l4zy0n3

Check, I remember I used to unlink the target (/etc/localtime) before setting it, that might have gotten lost somewhere.

Update - unlink is present, it's still not working, tried adding the force flag in ln, did not work

What's the symptom? Or how can we confirm that this is an issue?

Torxed avatar Jun 01 '21 06:06 Torxed

Check, I remember I used to unlink the target (/etc/localtime) before setting it, that might have gotten lost somewhere.

Update - unlink is present, it's still not working, tried adding the force flag in ln, did not work

What's the symptom? Or how can we confirm that this is an issue?

  1. Set the timezone eg: Asia/Kolkata
  2. chroot after installation, verify /etc/localtime, reboot and verify
  3. Timezone is set to UTC irrespective of choice at the installer prompt

l4zy0n3 avatar Jun 01 '21 07:06 l4zy0n3

Perfect, I'll also take a look at it and see what's going on.

Torxed avatar Jun 01 '21 07:06 Torxed

Relevant code in the user_interaction library file:

def ask_for_a_timezone():
	while True:
		timezone = input('Enter a valid timezone (examples: Europe/Stockholm, US/Eastern) or press enter to use UTC: ').strip().strip('*.')
		if timezone == '':
			timezone = 'UTC'
		if (pathlib.Path("/usr") / "share" / "zoneinfo" / timezone).exists():
			return timezone
		else:
			log(
				f"Specified timezone {timezone} does not exist.",
				level=logging.WARNING,
				fg='red'
			)

dylanmtaylor avatar Jun 02 '21 23:06 dylanmtaylor

And here's where we set it: https://github.com/archlinux/archinstall/blob/2731f82d0fd51e87c9c4454a25e1e01f2ae077cf/archinstall/lib/installer.py#L192-L212

Torxed avatar Jun 03 '21 08:06 Torxed

I'm wondering if we should swap arch-chroot in favor for archinstall.Boot() and set this via timedatectl instead (required systemd/dbus). I suspect it's this call that is unreliable because of potential mounts by arch-chroot or something: https://github.com/archlinux/archinstall/issues/533#L205

Torxed avatar Jun 03 '21 08:06 Torxed

I can see /etc/localtime is linked to ../usr/share/zoneinfo/UTC (notice it's starting with ..) after the reboot after install. I have configured to use NTP (I think guided.py can add an option to use systemd-timesyncd). By the way, you don't need to use arch-chroot to create a symbolic link, ln -s /usr/share/zoneinfo/{zone} {self.target}/etc/localtime is ok.

mytbk avatar Jun 13 '21 09:06 mytbk

By the way, you don't need to use arch-chroot to create a symbolic link, ln -s /usr/share/zoneinfo/{zone} {self.target}/etc/localtime is ok.

I believe that's what I used to do, not sure why I added the arch-chroot there. Just adds complexity hehe. Will re-work that in a bit.

Torxed avatar Jun 13 '21 12:06 Torxed

@Torxed I checked the installed version and the time seems to be set correctly

svartkanin avatar Sep 04 '22 09:09 svartkanin

@Torxed I think we can close this

svartkanin avatar Apr 30 '23 09:04 svartkanin