Skip to content

Instantly share code, notes, and snippets.

View PatrickLang's full-sized avatar

Patrick Lang PatrickLang

  • Washington, USA
View GitHub Profile
PatrickLang /
Created November 23, 2023 01:18
How to restore a WSL2 distribution and your data after a Windows Reset

I had some bad driver issues that led to me need to 'reset' Windows from the local recovery partition. This recovered my machine and got it bootable again. Afterwards, WSL2 wasn't installed, so I tried to install it. It rebooted, etc, then fetched Ubuntu 22.04 from the Microsoft Store as usual. However, instead of keeping my previous WSL2 content it started a new user:

Ubuntu is already installed.
Launching Ubuntu...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit:
PatrickLang /
Last active October 6, 2022 05:37
Testing SuSE Advanced Linux Platform (ALP) on Hyper-V


The initial [ALP Announcement] was this week, and the [ALP Deployment] instructions only cover how to test it on KVM. Since all of the support needed for Hyper-V is in upstream Linux, I thought I would give it a try. Technically this is all feasible, it's just a matter of making sure the right kernel options (or modules) are compiled in, and that the VM is configured appropriately

What's Needed

  • Get the qcow image from [ALP Download]
  • Download a qemu-img build for Windows from my friends at CloudBase
PatrickLang /
Last active November 12, 2023 04:46
Cleaning up Alsa + Pipewire for Focusrite Scarlett series

These are just some notes on how I'm trying to clean up Linux support a bit to make the Focusrite Scarlett 18i8 (gen2) and 2i4 a bit easier to use.

Getting UCM profiles

Currently having issues getting a clean test run on upstream project. See failing history

PatrickLang /
Last active June 23, 2022 06:12
learning about systemd-oomd

systemd-oomd was enabled by default in Fedora 33, and more recently Ubuntu 22.04. After trying some large software builds on these distros, I ran into some unexpected problems.

Overall, I think this is a good thing for most users, but I need to tune the defaults for cases where I'm willing to give up some responsiveness for reliability under heavy load.

Hard learnings

Where'd my build go?

  • Don't run a huge build process with too many threads in Gnome Terminal. Each one has its own cgroup slice, and if too much memory/swap are consumed or too much pressure - the slice is killed. You can't see what was going on when it was killed unless you were tee'ing it to a file
  • Podman also creates 1 cgroup slice per container, but at least you may be able to get some clues from podman container ls and logs
PatrickLang /
Last active July 8, 2021 05:41
CircuitPython on Adafruit RP2040 feather

Just a collection of snippets from when I was testing out the RP2040 feather

PatrickLang /
Last active November 23, 2023 19:07
Testing drm-hyperv driver in Fedora

Fedora 35

Both the issues mentioned below are solved! My PR to switch to hyperv_drm was accepted, and the kernel fix needed to boot the liveCD are in.

You can boot this as a generation 2 (UEFI) VM with secure boot enabled, using the Microsoft UEFI Certificate Authority setting. Resolution switching works in GNOME under Wayland, even when booted from the live media.

Fedora 34

This is a brief experiment I did to compare these two setups in a Hyper-V VM running Fedora 34

PatrickLang / Fedora34-VM.ps1
Last active September 27, 2023 10:31
Hyper-V example setup for Fedora 34
# Echo the commands as they're run
Set-PSDebug -Trace 1
# Dump Windows version
Get-ComputerInfo | Format-Table WindowsVersion, OsVersion
# Create a UEFI VM, secure boot enabled, use the secure boot settings for the
$vm = New-VM -Generation 2 -Name "Fedora 34 beta" -Path .
$vm | Set-VMFirmware -EnableSecureBoot On -SecureBootTemplate "MicrosoftUEFICertificateAuthority"
PatrickLang /
Last active February 4, 2022 04:40
Tracing Bluetooth Audio in Windows 10

Collecting the trace

Windows has the tools needed to collect traces for the bluetooth stack built-in, they just need to be configured. There are step by step instructions and scripts at Microsoft/busiotools, but I have copied some of the relevant details below.

To start the trace, create a temporary directory, then run this from an admin PowerShell prompt:

wget -outfile .\BluetoothStack.wprp
PatrickLang /
Last active April 9, 2021 06:14
Fedora 34 Jam Notes

Crash adding inputs - currently not repro

Investigating issue:

@wtay suggested trying jack_lsp after a failure. Installing that.

sudo dnf download --downloadonly jack-audio-connection-kit-example-clients.x86_64
sudo rpm -i --nodeps jack-audio-connection-kit-example-clients-1.9.16-2.fc34.x86_64.rpm
PatrickLang /
Last active March 4, 2023 19:59
Fedora 33 Notes

This is just a few things I'll probably forget later

Dual boot with encryption & hibernation

  1. Disable secure boot in BIOS if you want hibernation in Linux
  2. Shrink Windows partition using diskmgmt.msc
  3. Boot off Fedora live ISO
  4. Choose install, do manual partitioning with blivet
  • Mount existing EFI partition at /boot/efi
  • Create /boot partition