js' blog

Linux on the ASUS ROG Zephyrus G14 2021
Created: 05.09.2021 12:28 UTC

A few months ago, I got an ASUS ROG Zephyrus G14, 2021 version. I got it with the 5900HS, 32 GB RAM, RTX 3060, 1440p 120 Hz display and 1 TB of SSD. I never would have imagined that I would buy a gaming notebook, but AMD's current notebook offerings convinced me and this was the best machine in 14" that I could find (the Razer Blade 14 has been released since, but that's limited to 16 GB of soldered RAM). It doesn't feel like a gaming notebook, but rather an ultrabook with insane performance. Unfortunately, my vendor got a bad batch with display issues and sent me a replacement from the same batch several times, so the problem never went away, but that's a different story.

Today, I will talk about how to run Linux on the ASUS ROG Zephyrus G14 2021 and do most things the Armoury Crate software does on Windows without any extra software, as I have been asked to do so by a few people. There is also a project called "ASUS Linux" which has a guide for Fedora, which many people recommend, but I can only strongly recommend to not follow it: It severely weakens system security for absolutely no other reason than being lazy and I actually got banned from their Discord for raising these issues. There is a complete lack of understanding of concepts such as priviledge separation and priviledge drop and instead there's a daemon running as root. The author deems this absolutely secure because the daemon is written in Rust (history shows this to be a common misconception by those who have no clue about security - just because something is written in Rust doesn't make it 100% secure, it only eliminates a single class of security vulnerabilities) - while it links in various graphics libraries with a bad security track record to handle displaying images on the AniMe Matrix of the G14. So essentially, this is just one exploit in libpng or similar away from a full kernel compromize, because they also make you disable Secure Boot. And finally, they even tell people to install a custom kernel from Copr that has very questionable patches: E.g. adding udelay to avoid a race condition. For those who don't know what that means: That is a very ugly workaround that you should never ever do in production and leaves the underlying issue entirely unfixed.

But not everything coming from the ASUS Linux project is bad: The author actually did write some very useful patches and upstreamed them, so credit where credit is due. And it is also thanks to those patches that I can write this guide that works with a stock kernel. This just shows that upstream works: The good patches go upstream, while the bad ones don't. That's exactly how it should be.

First things first: You should use a distribution that has a modern kernel. For the G14 2021, that means 5.12 is the absolute bare minimum. I'd recommend 5.14 or, once released, 5.15, which should make standby more reliable. I'm personally using Fedora, but everything listed here should work with any distribution running a modern kernel and systemd.

The big elephant in the room for most people is probably the dGPU. By default, when no driver is loaded, it does not idle and sucks the battery empty in less than 2 hours. I've been told installing the NVIDIA driver fixes this, but personally, I do not use the dGPU on Linux other than for dGPU pass-through to a VM. So I will not install the NVIDIA driver, given that this only adds a lot of pain for no reason. If you do install the NVIDIA driver, that still does not require you to disabe Secure Boot - don't! Follow something like my last blog post instead on how you can set up your own Secure Boot keys and then you can just sign the NVIDIA kernel module with that. You also don't need the NVIDIA driver to pass the dGPU to a VM, in fact it's easier to do without the NVIDIA driver. But we would still like to have more than 2h of battery life, so there's an easy solution: Simply remove the NVIDIA card from the PCIe bus. You can automatically do this on every boot by creating a file /etc/tmpfiles.d/asus_gpu.conf and writing the following into it:

w /sys/bus/pci/devices/0000:01:00.0/remove - - - - 1
w /sys/bus/pci/devices/0000:01:00.1/remove - - - - 1

This way, the dGPU no longer uses any power. You can verify this (while running on battery, of course) using:

awk '{ print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now

You should get around 6 W when you dim the display and have an idle machine.

If you want to get the dGPU back, for example to pass it into a VM, simply rescan the PCIe bus:

echo 1 | sudo tee /sys/bus/pci/rescan

This machine also has 3 different fan profiles: Normal, silent and turbo. I personally like my machine to be entirely quiet and with the silent profile, the fans turn off completly if there is no significant load. I also like to be able to control the fan without needing to be root, from my regular user. To achieve both, create a file /etc/tmpfiles.d/asus_fan.conf and write the following into it:

z /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy 664 root js - -
w /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy - - - - 2

Important: Replace js with your username!

Once you have done that, you can use a script such as this to toggle through the profiles. I bind it to the fan key in GNOME and it even shows me a nice notification which profile I have selected.

Lastly, another feature of Armoury Crate is to not fully charge the battery to extend its lifetime. I am not sure how much difference this actually makes, alas, we can do the same on Linux. Just create a file /etc/tmpfiles.d/asus_battery.conf and write the following into it:

w /sys/class/power_supply/BAT0/charge_control_end_threshold - - - - 60

Replace 60 with whatever maximum percentage you want to charge it to. Obviously, you can also change this on the fly, e.g. if you want to charge to 100% again as a one-off before leaving the house:

echo 100 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

If you do that often, you might consider adding a z line similar to what we did in asus_fan.conf so that you don't need sudo.

That's it. If there's anything more you would like to do that Armoury Crate can do that I forgot about, please contact me and I'll have a look.