Installing Linux on 2022 Razer Blade 15"


Category: misc

While at Aurora, I became comfortable with using Linux on my work (ASUS GL503, Dell XPS 15 9520) and personal (Lenovo X1 Carbon Gen 6) laptops. As much as I can remember, I had minimal issues running linux on these machines, so I came to the (perhaps naive) conclusion that the Age of Linux was here. When picking out a laptop for research, the 15" 2022 Razer Blade caught my eye. Now that I've worked through most of the kinks, it's a joy to use, but getting here took some work. I found this post on fixing a number of issues and this post on selectively enabling the GPU very helpful, but there were still some hidden gotchas.

Installing Ubuntu 22.04

I followed these instructions to create a bootable USB. I popped the USB into the laptop, picked the USB drive as a boot device and picked "Try Ubuntu" from the menu, at which point it fails to boot. The issue is that included version of nouveau doesn't play well with the NVidia GPU. We can prevent the driver from being loaded by modifying the kernel parameters. Go back to the GRUB menu, highlight "Try Ubuntu" and press e to bring up the config editor. On the line beginning with linux, add nouveau.modeset=0. You should now be able to install Ubuntu as normal.

Updating the Kernel to Fix WiFi

Unfortunately, the kernel version that Ubuntu 22.04 ships with doesn't have support for the wifi card. Luckily, newer version of the linux kernel do have support!. First you'll need to disable secureboot in your bios to be able to run other kernels. There is probably a way to keep secure boot, but I haven't figured it out yet. Using a USB-C to ethernet adapter, install mainline, a tool that makes it easy to get a new kernel that was built by the ubuntu maintainers. At the time I installed Ubuntu, the latest version was 5.18.10. Once you have installed a newer kernel version, reboot your machine and pick your newer kernel version at the grub menu. Your WiFi should now be working!

Install NVidia Drivers

At the time of writing, the latest nvidia drivers can be installed by running sudo apt install nvidia-515. I also took the opportunity to install the latest version of PyTorch by running sudo apt install python3-pip, followed by pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116.

You can verify that this is working correctly if you get the following output from a python REPL. ``` ~ python3 Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import torch x = torch.zeros(10).cuda() x tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], device='cuda:0') ```

Note that the tensor that is on the GPU as noted by the device.

Fixing Suspend Issues

I learned more about linux power states when trying to fix these issues. The different power states are described here. Up until a few years ago, the most common low power states were Suspend to RAM (S3) and Suspend to Disk (S4). In Suspend to RAM, most components are set to a low power state, except for the RAM, in order to maintain the data in use. In Suspend to Disk, the contents of RAM are written to disk and all components are put into a low power state. The main behavioral difference between the modes is that S4 has the best power savings but S3 is faster to resume. A few years back, Windows started to pioneer a new set of low power states known as SOix, which allow the computer to go into a low power mode, but maintain network connectivity. This requires tight integration between the BIOS and the OS which has meant that Linux support has lagged a bit here. As a result, most linux systems continue to use S3, but on the Razer Blade, the touchpad becomes very laggy on wake up, rendering it unusable.

Fix Automatically Waking on Suspend

The laptop will stay in suspend as long as there are no detected wake up triggers. The trigger sources and whether or not they are enabled or disabled can be seen by running cat /proc/acpi/wakeup. To toggle whether or not a device is enabled or disabled, you can write the name of one of the sources to this same file. (e.g. echo "LID" | sudo tee /proc/acpi/wakeup). However, this change can't be persisted, for reasons I don't totally understand. To work around this, abarry suggests creating a systemd service to prevent RP05 from issuing wakeup requests.

Fix Failing to Wake after Suspend

If you restart your computer, I found that the kernel would fail to boot due to some NVidia issue. This GitHub Issue suggests adding ibt=off as a kernel parameter to fix the issue. Additionally, I needed to add nvidia-drm.modeset=1.

Reducing Power Consumption in Suspend

With the fixes above, the laptop will drain about 10% per hour while in suspend. This is because the GPU isn't entering a low power state. Here, abarry suggests adding some config for the NVidia kernel module to enter low power states. This brought battery drain down to about 2% per hour. Running Intel's S0ixSelftestTool seems to suggest that we aren't fully entering the lowest power state. It seems to be like the NVMe drive isn't playing well, but I haven't dug any deeper.

Fixing Microphone

It appears that there are multiple input channels and by default, the audio driver expects that the microphone is connected to the first interface (PDM0). However, on this machine, the microphone is actually connected to the second interface (PDM1). A long term fix is making it's way to the kernel, but as a short term hack you can follow the instructions here.