On Debian 13 GNOME running Virtual Machine Manager LineageOS 23.0 virtual machine how to update the virtual machine time after restoring a snapshot?
Jul 13, 10:02am

To update the time in a LineageOS 23.0 virtual machine running under Virtual Machine Manager (virt-manager) on Debian 13 GNOME after restoring a snapshot, follow these steps:


1. Ensure Time Synchronization is Enabled in the VM

LineageOS (Android) does not natively support NTP (Network Time Protocol) in the same way as a traditional Linux system. However, you can ensure time sync is enabled:

  • Check if NTP is enabled: On the LineageOS VM, go to Settings > System > Date & time and ensure "Use network-provided time" is enabled.

  • If not syncing automatically:

    • Open a terminal in the VM (if available) or use ADB:
      bash
      adb shell
      su
      date -s YYYYMMDD.HHMMSS
      Replace YYYYMMDD.HHMMSS with the current time.

2. Configure QEMU/KVM Time Synchronization

Virtual Machine Manager uses QEMU/KVM, which can pass the host's time to the guest. Ensure the VM is configured to use the host's time:

  • Edit the VM's XML configuration:

    1. Shut down the VM.
    2. Open a terminal on the host (Debian 13) and run:
      bash
      virsh edit <vm-name>
    3. Locate the <clock> section and ensure it includes:
      xml
      <clock offset="utc">
        <timer name="hypervclock" present="yes"/>
        <timer name="hpet" present="no"/>
      </clock>
    4. Save and exit. The VM will now sync its clock with the host.
  • Alternative: Add a host time source by adding:

    xml
    <clock offset="utc">
      <timer name="hypervclock" present="yes"/>
      <timer name="kvm-clock" present="yes"/>
    </clock>
  • Restart the VM for changes to take effect.


3. Force Time Sync via QEMU Guest Agent (if available)

If your LineageOS VM has the QEMU Guest Agent installed (unlikely by default for Android, but possible with custom kernels):

  1. Ensure the agent is running in the VM.
  2. On the host, check if the agent is connected:
    bash
    virsh qemu-agent-command <vm-name> '{"execute":"guest-ping"}'
  3. If available, force a time sync:
    bash
    virsh qemu-agent-command <vm-name> '{"execute":"guest-set-time", "arguments": {"time": "<current-utc-time>"}}'

4. Manual Time Sync via ADB

If the above methods fail, manually set the time via ADB:

  1. Connect to the VM:

    bash
    adb connect <vm-ip>:5555
  2. Open a shell:

    bash
    adb shell
    su
  3. Set the time manually:

    bash
    date -s YYYYMMDD.HHMMSS

    Example:

    bash
    date -s 20260713.143000
  4. Verify:

    bash
    date

5. Check Host Timezone

Ensure your Debian 13 host has the correct timezone:

bash
timedatectl

If not, set it:

bash
sudo timedatectl set-timezone Europe/Paris

6. Restart the VM

After making changes, restart the VM to ensure all settings take effect.


Why This Happens

  • Restoring a snapshot reverts the VM's state, including its internal clock.
  • Android (LineageOS) does not always sync time automatically in a virtualized environment.
  • QEMU/KVM may not pass the host's time correctly without explicit configuration.

Next Steps If the time still drifts, consider installing a custom kernel in LineageOS with better timekeeping support or using a time sync app from the Play Store.

Jul 13, 10:02am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more