Skip to content

Commit

Permalink
Hibernation works fine. Add "Resume from Hibernate has the wrong time"
Browse files Browse the repository at this point in the history
  • Loading branch information
jyap808 committed Jul 31, 2024
1 parent 757c8e6 commit c319a9f
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions content/pages/2024-04-04-1712257725.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ draft: false

I have installed Arch Linux on a Microsoft Surface Book 3 to use as my "focus" machine. This page outlines some things I've had to install and tweak.

Most everything [works out of the box](https://github.com/linux-surface/linux-surface/wiki/Supported-Devices-and-Features#surface-books-and-surface-laptop-studio) except the cameras, which I've disabled in the BIOS. Suspend only supports [ACPI state 0 Suspend-To-Idle](https://www.kernel.org/doc/Documentation/power/states.txt) and eats up 20%+ of the battery life overnight. [Resume from Hibernate has keyboard issues](#resume-from-hibernate-has-keyboard-issues).
Most everything [works out of the box](https://github.com/linux-surface/linux-surface/wiki/Supported-Devices-and-Features#surface-books-and-surface-laptop-studio) except the cameras, which I've disabled in the BIOS. Suspend only supports [ACPI state 0 Suspend-To-Idle](https://www.kernel.org/doc/Documentation/power/states.txt) and eats up 20%+ of the battery life overnight, but as of kernel 6.9.9-arch1-1-surface I have not had issues with Hibernation.

This is *not* a recommended laptop for running Linux.

Expand Down Expand Up @@ -115,8 +115,44 @@ Appears to be an issue with the dock and using a USBC to Display Port cable.

Unplugging the power cable (which connects to the dock) seems to help get the external screen displaying again. Annoying workaround.

### Resume from Hibernate has keyboard issues
### Resume from Hibernate has the wrong time

Tracking the issue: https://github.com/linux-surface/linux-surface/issues/1412
Resume from Hibernate suffers from clock drift so has the wrong time.

The system Hibernates fine. Resume from Hibernate seems to work except some keys on the keyboard (both USB keyboard and built-in keyboard) didn't work on the one test I did. Was able to SSH into the laptop and reboot it from there.
To resolve this, I set up a systemd service that runs a time synchronization command when the system wakes up. Here's a step-by-step approach to implement this.

First, make sure you have the systemd-timesyncd service enabled and running. This is the default time synchronization daemon for Arch Linux. If it's not already enabled, you can enable it with:
```
sudo systemctl enable --now systemd-timesyncd.service
```

Create a new systemd service file:
```
sudo vi /etc/systemd/system/fix-time-on-resume.service
```

Add the following content to the file:
```
[Unit]
Description=Fix system time on resume from hibernate
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart systemd-timesyncd.service
[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
```

Reload the systemd daemon to recognize the new service:
```
sudo systemctl daemon-reload
```

Enable the new service:
```
sudo systemctl enable fix-time-on-resume.service
```

This service automatically restarts the systemd-timesyncd service when your system resumes from hibernation, which corrects the time.

0 comments on commit c319a9f

Please sign in to comment.