Let's Install Linux

When an easy task turns into a nightmare.

# Preface

I’ve wanted to try Linux for some time now but I never really wanted to give up any of my SSD space for it. After frequently browsing through nice linux themes, I too decided that my regular working environment didn’t have enough virtual a e s t h e t i c. So I got to work looking for tools to make Windows 10 pretty but the choices were only disappointing. Rainmeter was the only tool that got close to making the desktop look the way I wanted it to but it was only the desktop, no changes to rest of Windows’s UI.

Cut to a few months later when I couldn’t muster the effort to trawl through Windows’s C APIs to create my own task switcher, I managed to clear enough space off my SSD to put something big on but then I looked up SSD prices was surprised to find 120GB SSDs were now only £20. Installing on a separate SSD is nice because I could just nuke the whole drive to try out something else pretty easily. I ordered one and got ready.

# Picking a distribution flavour

So, so many nice looking distros out there. Here are just some of the ones I considered:

  • Arch Linux
  • CentOS
  • Linux Mint
  • Manjaro
  • Ubuntu

and desktop environments and window managers:

  • GNOME
  • KDE Plasma
  • Open Box
  • i3
  • XFCE

I whittled it down to Arch or Ubuntu and decided to go with Ubuntu 18.04 for the easier installation experience and less need to install a package for every task I would want to do. Ubuntu comes with GNOME which I quite like so I thought I would just stick with that.

# Installation

The actual installation, going from bootable USB to OS on SSD, was actually incredibly simple and fast. But this isn’t a story about how easy it is to install linux. First I had to disable fast boot in the BIOS otherwise I would see a black screen with a flashing white text cursor. I was only booting to black a screen so I had to use the nomodeset grub config line to get to an interface I could see.

The problem was, the GPU drivers weren’t working at all. In fact, something was very wrong—rendering was hilariously slow. Dragging windows involved so much latency you could see each pixel row of the window draw one by one from top to bottom. Any transparency effect that covered the screen looked like a macOS unexpected error screen as the grey background slowly moved from top to bottom. I’d never seen anything like it, a huge frame buffer transferral bottleneck. Using a 2560x1440 resolution monitor probably didn’t help this situation.

Almost all of these consequent problems were caused by one thing: my AMD R9 390 GPU.

# Fixing GPU Drivers

The AMD 390 doesn’t exactly have the best reputation with linux. In essence, there seemed to be a bug related to power delivery in the GPU drivers that was never found for 2 and a half years until AMD rewrote their power delivery system and the bug “magically” went away. Even though these fixes were included in a linux kernel update, they don’t seem to be applied by default which is what started my descent into madness.

I dug deep through an unprecedented number of askubuntu, reddit and forum posts to try to find people having similar problems to me. I used the search queries “Ubuntu 18.04 AMD 390 -nvidia llvmpipe software renderer black screen” in an algorithmically disturbing number of permutations to try to find answers.

Here were a things I tried to fix the problem to no avail.

  • Change secure boot setting from Windows UEFI to Other OS.
  • Set nomodeset in grub config and sudo update-grub to update.
  • sudo apt update && sudo apt -y upgrade.
  • Update the kernel from 4.15 to 4.19 using UKUU.
  • Set radeon.cik_support=0 radeon.si_support=0 amdgpu.si_support=1 amdgpu.cik_support=1 amdgpu.dpm=1 amdgpu.dc=1 in grub config.
  • Install latest drivers with sudo add-apt-repository ppa:oibaf/graphics-drivers && sudo apt update.
  • Blacklist radeon in /etc/modprobe.d/blacklist.conf and update with sudo update-initramfs -u.
  • Make a /etc/X11/xorg.conf file and put in
Section "Device"
    Identifier "AMDGPU"
    Driver "amdgpu"
    Option "AccelMethod" "glamor"
    Option "DRI" "3"
EndSection
  • Install apt install libegl-mesa0 which seemed to be missing.
  • Install AMDGPUPRO drivers from AMD’s website versions 18.30 and 18.40.
  • Realise nomodeset disables AMDGPU drivers and removed it.
  • Type my encryption key into a completely blank screen to get past the encryption screen.
  • Previous things in various combinations.

I also discovered some notable and some unexplainable things:

  • There are 3 main drivers for amd gpus: radeon (old), AMDGPU (open source), AMDGPUPRO (closed source).
  • I could only pick from 4 resolutions monitor: 3 very low ones and native 2560x1440.
  • Grub was very slow and froze if I pressed keys too fast making it difficult. As I needed to press keys to get to the grub menu, I was forced to play this strange timing minigame.
  • F8 on my motherboard (ASUS thing) brings up boot menu.
  • Arch Wiki Page has good info about AMDGPU, even a section specifically dedicated to fixing R9 390 problems.

One thing that I did “fix” during all of this was that software renderer performed much faster but it was still not quite right, my GPU still appeared as llvmpipe in the settings and videos played with strange V-sync issues.

# Redemption

At this point I had run out of options so I decided to just start anew. This time I used Ubuntu 18.10 instead, maybe it would improve.

I was booting to a black screen and when I couldn’t get to grub (holding shift did nothing) I had to spam ESC and then type normal to get back to the menu and then spam ESC again so it didn’t automatically move on. Added radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dpm=1 amdgpu.dc=1 to grub config. GPU recognised, everything works fine.

Why?

I don’t know. Either I broke something trying different fixes or version 18.10 and it’s kernel took more of an interest in talking to my GPU.

# I <3️ high refresh rate

Next problem: nothing was smooth. I have a 144Hz monitor and am used to buttery smooth scrolling, window dragging and games from Windows. The only thing that seemed to render at 144fps was the cursor.

Unfortunately GNOME seems to be hard-coded to 60Hz which was a real let down. I was surprised by how few people on the internet were concerned with this; apparently the overlap between linux enthusiasts and hardcore gamers was nowhere near as prevelant as I imagined. I did find some people who seemed to be able to recompile the entire desktop environment with new config values and get it to work but I don’t know if I was prepared to go down that route, I wasn’t quite ready to take on that many dragons today.

So I installed Kubuntu for the KDE Plasma environment. I didn’t realise that the default theme for KDE5 is actually very nice! It supported 144Hz and now everything is back to being super smooth.

Post mortem note:

Operating system related UI renders at 144Hz but support is very shaky on an application by application basis. Firefox renders at 144Hz as long as the rendering frame rate is set in the developer options. Chrome, and therefore all Electron applications (including VS Code and Discord), do not render at 144Hz and I can’t find any workarounds. Help.

# Reanimating Windows

My next major problem: I couldn’t boot back into Windows. It didn’t appear in grub and booting from my BIOS would bring up grub rescue with the error no device found, unknown filesystem. I wasn’t really worried about losing my files because I could still see them in ubuntu.

I tried lots of different things to try to get grub to recognise it (mounting, update grub, reinstall grub, boot-repair) but nothing seemed to work. I have a recovery partition but I couldn’t access it.

I may have done some unnecessary operations when running boot-repair which included installing grub onto the Windows SSD or hard drive. Doesn’t seem to have had any adverse affects but woops, I should remember to clean that up one day.

os-prober didn’t list anything, even after mounting all my ssd partitions. I later found out that this may be caused by me installing Ubuntu in EFI mode and Windows is in legacy boot mode (which I didn’t think it was). Ubuntu 18.04 (previous install) did recognise Windows so I wonder if I installed it in legacy boot mode without realising.

Anyway, I decided to find a USB and install the Windows 10 ISO to run the repair but doing this on Linux ended up being more a pain than I anticipated.

  • Startup Disk Creator didn’t do anything when I selected it as an input.
  • unetbootin’s apt repo wasn’t updated for 18.10
  • Using unetbooting’s binary, the installation got stuck on the 465th file, twice.
  • Restore Disk Image in Ubuntu’s Disks worked but it didn’t boot properly.
  • Trying to install WinUSB uninstalled grub (so it could use a different grub) so I had to reinstall it and didn’t work anyway.
  • Found out WoeUSB is a more up to date fork, installed with apt, it made the bootable USB.

The BIOS recognised the USB as two different boot drives (one was EFI). EFI Startup Repair failed and for some reason didn’t say the location of its log. Legacy Boot Startup Repair failed and for some reason didn’t render in the correct resolution.

After this I tried running the following commands while USB was booted in legacy mode to try to fix the sacred master boot record or MBR for short.

bootrec /RebuildBcd
bootrec /fixMbr
bootrec /fixboot

First two were successful, third command resulted in access denied.

bootrec /ScanOS

Said it didn’t recognise any successful installations.

Tried to boot Windows 10 again: it worked fine. Don’t know why, don’t know how, thank god I’m not an IT professional. Grub doesn’t recognise it (probably because it’s installed in a different mode) but I can reliably get to Windows using the BIOS.

# Epilogue

Installing linux is not for the faint of heart, probably.

There’s a high chance that you won’t run into any of problems that I’ve come across. I’ve already lost hours and hours to fixing linux problems and I haven’t even started to use it yet. I have to say, as a programmer and a person who tries too hard to make things work; this type of experience was nothing new but it was pretty distressing. Turns out computers are pretty complicated or something. I made this document to make sure I won’t forget anything next time I come to install a new distro.

Things still aren’t quite perfect; for some reason the cursor appears differently in electron apps and in Opera, it isn’t anti-aliased. Some of these oddities I think I’ll have to live with, but because this is linux, there is also a good chance of tackling them.

Although a painful adventure, I’m happy that I now get to start playing around with theming and making things look super pretty!