Arch Linux kernel and NVidia recent bugs

I was facing frequent freeze of the laptop recently. The discussion can be found here.

Basically, there are two issues, one is the Linux kernel, and the other is the NVidia driver update.

Linux kernel causes some Oops in the kernel, probably related, I don’t know. The result is that I can’t shutdown my laptop because it cannot unmount /home and /tmp. To resolve this, I upgraded the Linux kernel to 6.7.8, and added zswap.enabled=0 and numa=off as the kernel parameter, in GRUB. I am not sure which one is the actual action that solve the issue.

Another issue that drives me crazy is the NVidia. Since NVidia 545, the laptop will freeze suddenly. After several trials, I change to nvidia-open-dkms. Besides that, I also experienced switching the TTY causing the black screen but the mouse is visible and movable. This is slightly different from the discussion on the forum, in which the other users reported having a black screen with a visible mouse after resuming from suspend to memory (sleep). After much trial and error, I found that the compositor picom caused the issue. If I kill picom, then there is no issue when switching TTY, or even resuming from suspend to memory.

The forum suggested to use NVreg_PreserveVideoMemoryAllocations=1 for the black screen issue. I tried, but it doesn’t work. Probably I did it wrongly.

Arch Linux Xorg failed to run

Today I updated the packages, then rebooted, then the machine got stuck at

[Started] Accounts Service

Seriously, I have had no issues with my laptop recently. And this makes me nervous. It will be troublesome if I have to boot into the Arch Linux LiveUSB. But luckily, searched online, and someone mentioned to change to another TTY with Ctrl+Alt+F2.

Wheew. I still can log in with the command-line. And then I noticed that, the issue must be NVidia driver related.

Since I faced the backlight bug of NVidia 545 driver, I have ignored the NVidia related packages during upgrading. Besides that, I am using DKMS as well. During the upgrading, I didn’t notice the following error

Error! Bad return status for module build on kernel: 6.7.3-arch1-1 (x86_64)

As a result, this causes lightdm failed to run.

With the alternative TTY, I install all the latest NVidia packages (545.29.06) and re-install the Linux kernel, DKMS builds without error.

Reboot, problem solved!

P/S: However, I found that I cannot resume from suspend to RAM properly, though sometimes there is no issue. I can see a black screen with a mouse moving, but not able to change to another TTY. This is super annoying. A similar issue is discussed here.

Android playing iOS MOV video

I am using an Android phone, specifically Vivo. I found that when I play the MOV video transferred from iOS, only sound is able to be played properly but the picture is not showing.

None of the solutions from the Internet helped me to solve my problem. After trial and error, I found that the MOV file can be converted to MP4 format using ffmpeg with some parameters. Eg,

fmpeg -i input.MOV -c:v libx264 -c:a aac -vf "scale=720:1280,fps=29" -ac 1 -x264opts "ref=0:cabac=0:b_pyramid=0:bframes=0" -profile:v baseline -pix_fmt yuv420p output.mp4

Based on my experience, the most crucial parameter is “-pix_fmt yuv420p”, so the MP4 video is 8-bit depth.

Switching from Openbox to IceWM

Bye-bye Openbox, welcome IceWM.

Due to the recent upgrade of glib2 on Arch Linux, it crashes my Openbox when I am running Wine or Proton. Downgrade to 2.74.6 is not a solution, because Nemo, Caja, Nautilus are using 2.76.0.

As a result, I have to find an alternative. From Wikipedia, I found that LXDE can be configured with other window manager rather than Openbox, eg Fluxbox, IceWM, or Xfwm.

I tried Xfwm, but it fails to run. Probably needs extra configuration, but I didn’t continue trying. I tried Fluxbox long time ago, can’t remember the feature. Then I found that, compare to Openbox, IceWM is still in development. Hence I decided to try IceWM.

After installation, I just need to configure it so that it resembles Openbox behaviour, especially the shortcut keys.

The following is the list of prominent configuration I did:

  • Install dex to start XDG autostart applications
  • Use shutdown script to pkill -u myusername , so that all the processes will be stopped/killed when I logout
  • Hide the taskbar (ShowTaskBar=0), because I use tint2
  • Use prefoverride to replace the default background image. Though, I am still using feh script to show random wallpapers
  • Window related shortcut keys are edited in preferences file; launching application shortcut keys are edited in keys file

For shortcut key to toggle a window as always on top, it requires editing keys file with the following line,

key "Alt+F12" sh -c 'if icesh -f getLayer | grep -q 'OnTop' ; then icesh -f setLayer Normal ; else icesh -f setLayer OnTop ; fi'

Note: Make sure the key such as “Alt+F12” has no conflict in preferences file. If it exists, just empty the value in the preferences file.

Some limitations I faced:

  • I cannot use Numix theme anymore
  • Alt+Ctrl+Del (system dialog) has a strange behaviour if I cancel it. I can’t type on any window after cancel, unless I switch the workspace.

As a conclusion, I just need to adapt to this new window manager. Bye-bye Openbox.

Migrate to SSD

In my previous post, I mentioned I have boot issue. Then I asked in Arch Linux BBS, and I got some useful advice from other users. As a result, I contacted a computer shop in my town, in order to get a hard drive (HDD). However, the shop doesn’t have 7200 rpm HDD. Then he suggested SSD to me, which is 1T storage. The SSD now is much cheaper comparing to two years ago.

I remembered that SSD, requires some special configuration, due to “limited write-life” [1]. Spending around one week time, I searched for the recommended tweaks and modified the setup in order to cope my working environment.

The following is the summary of my SSD configurations:

  1. The partitions should be mounted with noatime option.
  2. When creating partition, should be aligned properly, which fdisk should handle it automatically. [2]
  3. Enable fstrim
  4. Do not use swap partition, as fstrim does not work on swap partition [3][4]. Though, “swap system has automatically supported TRIM capable devices” [5]
  5. 8G RAM is not enough for my working environment. I created swap file instead of swap partition
  6. Set swappiness [6]
  7. If 8G RAM is enough, then can use zram (using zram-generator).

[1] Dell, “Hard Drive – Why Do Solid State Devices (SSD) Wear Out,” Dell.com, Sep. 28, 2021. https://www.dell.com/support/kbdoc/en-my/000137999/hard-drive-why-do-solid-state-devices-ssd-wear-out. (accessed Apr. 14, 2022).

[2] “Should I align partitions on an SSD, if so how do I do it at install time?,” Ask Ubuntu, Dec. 26, 2010. https://askubuntu.com/questions/18900/should-i-align-partitions-on-an-ssd-if-so-how-do-i-do-it-at-install-time#18951 (accessed Apr. 16, 2022).

[3] “fstrim does not trim swap,” Unix & Linux Stack Exchange, Dec. 12, 2019. https://unix.stackexchange.com/questions/556805/fstrim-does-not-trim-swap#558223 (accessed Apr. 16, 2022).

[4] “why not use Swap file on SSDs instead of Swap partition?,” Ask Ubuntu, Nov. 11, 2016. https://askubuntu.com/questions/848230/why-not-use-swap-file-on-ssds-instead-of-swap-partition?noredirect=1&lq=1#1290562 (accessed Apr. 16, 2022).

[5] “SwapFaq – Community Help Wiki,” Ubuntu.com, 2022. https://help.ubuntu.com/community/SwapFaq (accessed Apr. 16, 2022).

[6] Why, “Why are swap partitions discouraged on SSD drives, are they harmful?,” Ask Ubuntu, Jul. 24, 2015. https://askubuntu.com/questions/652337/why-are-swap-partitions-discouraged-on-ssd-drives-are-they-harmful#964933 (accessed Apr. 16, 2022).


Med: Experimental feature

I just tested with my new experimental feature for Med (Linux Memory Editor) on Sea Dogs, i.e. Custom Scan.

Sea Dogs is very difficult to do memory editing, as the values are stored in string. Luckily someone wrote a superb guide on how to do memory editing, which can be found here.

But the problem is that, the guide is written for CE (Cheat Engine). Unfortunately, CE is for either Windows or Mac. And to cheat in Sea Dogs, need to use “Group Search” feature of CE. WTF is Group Search?

After some studies from here, finally I wrote similar feature on Med. The related source code can be found here (not yet merge into master branch). I use similar syntax as CE’s Group Search.

s:'6', w:87, s:'5', w:31, s:'5', w:151, s:'6', w:31, s:'7', w:159, s:'7', w:199, s:'6'

The current code in Med uses block alignment 8, which cannot be changed, since I am doing experiment. Different from CE, I use comma separation instead of space separation. The s is string, follows by single quotes, w is wildcard. So far I only wrote the code for s and w. Nothing else.

Yeah! Now I can play the protagonist as superman.

LightDM background image

Recently my old laptop, due to some unknown configuration, it shows a background image in the LightDM login. It is annoying, and it is user specific. Meaning, if I choose another user, the background image will be changed to black background.

Searched for the solution on Internet, most of links are about gsettings, or edit the image in /etc/lightdm/lightdm.conf. But none of the related to my issue.

Finally, I found the solution. The problem is not LightDM itself, but related to AccountsService.

To solve the issue, edit the /var/lib/AccountsService/users/[username], there is a line

[org.freedesktop.DisplayManager.AccountsService]
BackgroundFile='/path/to/custom/image.jpg'

That’s the culprit. Remove or comment out the BackgroundFile, then the problem solved.

Patch Wine and supports both 64-bit and 32-bit

We can build Wine that supports both 64-bit and 32-bit.

The below shows the example that involves patch of a specific Wine version. Sometimes official or latest Wine just doesn’t work. And the patches can be found in the bug report attachment.

Download a patch from Wine bug report, and download the source code. Extract the source

tar xJf wine-4.2.tar.xz
patch -u -p1 < ../swshader_ivb.patch

To build Wine that can work on both 64-bit and 32-bit, we can follow this.

The following is the script to build wine.

#!/bin/bash

srcdir="$(pwd)"
mkdir build-64 build-32

cd "$srcdir/build-64"
../configure --prefix=$HOME/mywines/wine-4.2-sw-blend \
  --libdir=$HOME/mywines/wine-4.2-sw-blend/lib \
  --enable-win64 --with-x
make -j4
cd "$srcdir/build-32"
PKG_CONFIG_PATH=/usr/lib32/pkgconfig ../configure \
  --prefix=$HOME/mywines/wine-4.2-sw-blend \
  --libdir=$HOME/mywines/wine-4.2-sw-blend/lib32 \
  --with-wine64=$srcdir/build-64 \
  --with-x
make -j4

cd "$srcdir/build-64"
make install
cd "$srcdir/build-32"
make install

Now, you can use the this Wine to run specific game.

A Wine wrapper script can be found here

NVIDIA with Nouveau and Wine

I updated my old laptop HP Pavilion dv3 (2238tx) recently, which was bought in year 2010, installed with Arch Linux.

Because of Linux kernel version, the NVIDIA driver is not officially supported by Arch Linux (detail).

There are two options to resolve this: install (i) Nouveau or (ii) NVIDIA driver from AUR. The former is open source, the latter is closed source from NVIDIA official site. Furthermore, using the latter theoretically allows the usage of CUDA, which is important if I am using it to do some neural networks training.

Now, since this old laptop, 说好不好,说坏不坏, I tried to install games. Unluckily, the Windows 7 (it is dual boot) is 32-bit, which I don’t plan to re-install new version of Windows with 64-bit. So, I am trying to figure out Linux Wine whether it can work or not.

Firstly, I tried PlayOnLinux to install 64-bit Wine. But I found that 64-bit Wine in PlayOnLinux can run only 64-bit programs. Then after some study, I found that Arch Linux official Wine package supports both 64-bit and 32-bit.

So, I wrote a Bash script to do something like PlayOnLinux which can be found here, so that I can isolate the WINEPREFIX for different programs, and allows to use different versions of compiled Wine.

After some trial and errors, I make an almost 9 years old laptop to run a 64-bit game released in 2018, though the performance is not very good.

The followings are the setup/configuration:

  • Nvidia G98M (GeForce G 105M)
  • Nouveau and related packages like “mesa”
  • Wine 4.13
  • VirtualGL (Not sure whether it is required)
  • Winetricks and installed “d3dx9” (Not sure whether this is required)

Chinese (and CJK) fonts

I am using Arch Linux, and recently I found that my fonts are little different after upgrade.

In DBeaver, the monospace font shows this:

This causes the monospace doesn’t follow the same width. And I found that, the default “Monospace” doesn’t use DejaVu Sans Mono anymore after the recent upgrade.

After looking some solutions, I tried edit ~/.conf/fontconfig/fonts.conf according to this this one.

<match target="pattern">
  <test qual="any" name="family"><string>monospace</string></test>
  <edit name="family" mode="assign" binding="same"><string>DejaVu Sans Mono</string></edit>
</match>

The above solution solves the monospace in most applications like Mousepad and DBeaver.

But then, I found CJK issue in Mousepad when using monospace font, like this,

The Simplified Chinese font and Traditional Chinese font are different.

If open with “charmap” and choose Monospace font, we can check what are the fonts being rendered, like this

I right-clicked the character, found that two fonts are being used in Monospace for these Chinese characters: Meiryo and KaiTi. Meiryo was installed with “ttf-vista-fonts” package, and KaiTi I installed directly to ~/.local/share/fonts.

After some study, I found that the above fontconfig is not good enough. Lastly, I changed my setting to

<alias>
  <family>sans</family>
  <prefer>
    <family>DejaVu Sans</family>
    <family>WenQuanYi Zen Hei</family>
  </prefer>
</alias>
<alias>
  <family>monospace</family>
  <prefer>
    <family>DejaVu Sans Mono</family>
    <family>WenQuanYi Zen Hei</family>
  </prefer>
</alias>

After saving the changes, the application must be restarted in order to see the effect.

And this finally solved the font issues.