Drew Lustro  ·  bootleg hypertext

Troubleshoot a GPU or Motherboard Upgrade on Linux

Fractal Design Node 202 ITX Build i7-6700 Linux Boot

The following article outlines tips and common pitfalls to smooth your motherboard or GPU upgrade experience on GNU/Linux. More broadly, all troubleshooting advice is applicable to generalized boot / discrete GPU difficulties.

This article assumes a general understanding of GNU/Linux and focuses on an Ubuntu/Debian derived distribution. Personally, I am running KDE Neon User Edition 5.8.x, but your desktop environment may vary.

Table of Contents

Preparation

Physically Build New Machine

Fix Common Boot Issues Post-Build




The Scenario

I have a dual-boot Ubuntu + Windows 10 machine that I recently migrated from a standard ATX motherboard to the far more compact, elegant ITX form factor. I took the opportunity to also upgrade the processor and GPU to Nvidia's latest architecture.

Build the new ITX PC, move the drives, plug everything in, and it just works right? Not quite. There were headaches and countless reboots that, in retrospect, could have been largely avoided with a little prep.

First, let's set the stage for the upgrade:

Original ATX Parts List

New ITX Parts List

Critical Drives To Migrate




Prepare Linux for Migration

Perform a standard update & upgrade with apt:

sudo apt update
sudo apt upgrade

Prepare a Linux Live or Boot Repair USB Flash Drive

A bootable GNU/Linux flash drive is essential. It allows you to most efficiently fix boot issues and inspect system hardware in a stable, temporary desktop environment. You can use the installer image of almost any major Linux distribution.

A More Conservative /etc/fstab

Upon boot into a new environment, many Linux installations will force a disk check with fsck on available drives. This is normal and will usually complete without issue. However, if some drives are missing in the new motherboard environment, or a partition address has been brittlely defined in /etc/fstab, you may experience hangs or incomplete boots.

sudo vim /etc/fstab # or use your editor of choice

Let's make /etc/fstab more conservative:

  1. Comment out any physical drives that will not be available in the new PC.
  2. Comment out any network drives until you have a fully operable desktop environment.
  3. Leave the essentials: root partition, swap partition, and (if exists) home partition.
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>

# / was on /dev/nvme0n1p6 during installation
UUID=4d891674-f217-4c84-bfec-8ce5e848e322 /               ext4    errors=remount-ro 0       1

# swap was on /dev/nvme0n1p5 during installation
UUID=ac289fa2-55f4-42ca-9f95-30adb8764c95 none            swap    sw              0       0

# -- extraneous HDD commented out --
# Tokyo 2TB 3.5" Drive (for dropbox, etc)
# UUID=ac3616fe-8033-46db-b9d9-e93e373fcd97     /media/drew/Tokyo    ext4    defaults     0     0

# -- extraneous Samba/CIFS network drive commented out --
# SMB RAID5 network drive (/Volumes/Obsidian)
# Obsidian (Mac Pro Thunderbolt 2 Drive)
# //floating-point.local/obsidian /media/drew/Obsidian cifs uid=1000,gid=1000,credentials=/home/drew/.smbcredentials,iocharset=utf8,sec=ntlmssp,nolock,rw,x-gvfs-show,x-gvfs-name=Obsidian 0 0

Above, I have commented out Tokyo, a 3.5" drive I could not migrate to the ITX chassis due to space constraints, and Obsidian, a Samba/CIFS network share. The Samba share caused KDE Neon to repeatedly hang on boot because the network hardware had been assigned a new device identifier (more on that later on).

Linux GPU Drivers and Where to Get Them

This an nebulous and heated topic within the community, mostly due to shared frustration. Accelerated GPU drivers for Linux come from many places and in many forms:

  • open source, reverse-engineered drivers (nouveau or radeon)
  • proprietary vendor blobs via third-party PPA (ppa:graphics-drivers/ppa)
  • proprietary vendor blobs via (anecdotally unreliable) OEM installer script for vanilla GNU/Linux (Nvidia or AMD drivers)

It's a mess. Quality GPU acceleration has always been a moving target for the Linux desktop, and getting GPU drivers to play nice with Xserver has likely driven thousands of people insane. Allegedly, Wayland will save us from X11 tears and GPU artifacts uncommon on macOS and Windows, but that is another day, another article.

It is near impossible to predict whether your installation will survive a GPU upgrade without requiring recovery mode at least once (aka 'single-user' or 'maintenance' mode). If you get a blank screen or explosion of boot errors despite your best efforts, take a deep breath. It is okay. You are no fool. We've all been down this road of a bricked desktop environment, and it comes with the territory.

A login into the recovery root shell for this kind of troubleshooting can feel spooky, but you should have a vague idea of what to diagnose if problems arise.

Ensure you've added the third party graphics drivers ppa:

sudo add-apt-repository ppa:graphics-drivers/ppa -y
sudo apt update

Research which packages to install/remove upon first boot into the recovery shell. See what third-party drivers your current hardware requires via ubuntu-drivers devices.

$ ubuntu-drivers devices
== cpu-microcode.py ==
driver   : intel-microcode - distro non-free

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
vendor   : NVIDIA Corporation
modalias : pci:v000010DEd00001B80sv00003842sd00006180bc03sc00i00
driver   : xserver-xorg-video-nouveau - distro free builtin
driver   : nvidia-367 - third-party free recommended

Above, you can see my old ATX build w/ Nvidia GTX 970 employed the proprietary nvidia-367 driver. Generally speaking, each new Nvidia driver is cumulative in supporting new cards. This is why it is possible to have several nvidia-### packages that work fine with your video card.

At time of writing, nvidia-375 is the latest driver package, and it works with the GTX 1080. Run ubuntu-drivers devices, and make a mental note of which driver is in use. If you upgrade your GPU, you'll know which driver to remove after physical installation.

Change the setting GRUB_CMDLINE_LINUX_DEFAULT in Grub's boot configuration to boot verbosely. This will allow you to broadly see what's happening during OS initialization. Edit with sudo /etc/default/grub:

# find and change this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# to this:
GRUB_CMDLINE_LINUX_DEFAULT=""

# also, if you run into 'black screen' problems and
# want to force disable GPU acceleration:
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"

Save, close, and apply to Grub:

sudo update-grub

You may want to repeat this process several Grub installations across multiple partitions. Luckily, Grub options can be adjusted during the boot process, so it is not 100% necessary. I prefer to globally turn on verbose boot until I have a reliable, working system.




Physically Build New Machine, Migrate Hardware

Shutdown the machine. Break out the mobo tools and enjoy the build experience. Here are photos from my build:




Fix Common Boot Issues Post-Build

You've performed the hardware migration, boot for the first time, and something goes wrong. Boot hangs, kernel panics, countless error messages; stay calm, it's time to troubleshoot.

Important Note: All following troubleshooting tips assume a root # shell. Anytime Grub is reconfigured or new drivers installed, be sure to reboot.

No OS Detected

Ensure the BIOS Sees Expected Hardware: Press F2 or DEL on boot to enter the BIOS. Ensure all internal SATA drives are recognized by the BIOS. If not, open the PC chassis and confirm all SATA and power cables are routed correctly.

Grub Fails to Find Linux Installations

Use boot-repair to detect partitions that have Linux installed and perform fresh installations of Grub on each partition.

You can use the Linux Live USB flash drive to get a root shell. Force a boot from the flash drive with the BIOS. Once you get a desktop environment, fire up a terminal, add the boot-repair PPA, install, and run boot-repair:

sudo add-apt-repository -y ppa:yannubuntu/boot-repair
sudo apt-get install -y boot-repair
sudo boot-repair

Grub Finds Linux, Fails to Boot

No Login Prompt: On installations with a desktop environment, Linux will attempt to boot into it by default. If this process fails, you may be left with a blank screen and no login prompt. Access one of several virtual terminals with CTRL+ALT+F1, CTRL+ALT+F2, and so on.

The desktop environment (blank screen, in this case) is traditionally assigned to virtual terminal 7. You may return to it with CTRL+ALT+F7.

Disk Integrity Check: Some drives/filesystems may have been corrupted or marked dirty during the upgrade process. Use fsck to perform a disk check on all internal drives. On success, they will be marked as clean.

# identify your partitions
blkid

# run fsck on each partition (yours will differ)
fsck /dev/sda1
fsck /dev/sda2
# ...
fsck /dev/sda5
fsck /dev/sda6

Missing Mass Storage Device Drivers: You may need to regenerate initramfs for all kernels if your CPU architecture has changed dramatically.

# Create (-c) initramfs for all kernels (-k all)
update-initramfs -k all -c

Your old friend dmesg: The dmesg command is extremely helpful for clues. Use it to troubleshoot hardware problems by making mental notes of critical boot errors.

No Networking / LAN

Some generalized tips:

# restart the networking service (Ubuntu 16.04+)
systemctl restart NetworkManager.service

# restart the network manager via System V init script
service network-manager restart

# alternatively:
/etc/init.d/networking restart

# bring all network interfaces DOWN
ifdown -a

# bring all network interfaces UP
ifup -a

Suppress Network Device New Identifier Assignment: With a new motherboard, Ubuntu may assign new names to your network hardware that do not correspond to any existing configuration (commonly eth0, eth1, or wlan0).

For instance, your replacment motherboard's ethernet and wireless hardware could be assigned new idenifiers eth2 and wlan1, respectively. These new hardware idenifiers lack essential configuration in system files. Since the replaced network hardware no longer exists, it is safe to use the original hardware identifiers via Grub.

Force using the original device names with an edit to /etc/default/grub:

# change this:
GRUB_CMDLINE_LINUX=""
# to this:
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Be sure to apply these changes:

update-grub

Blank Screen; No Desktop

Install new GPU driver: Let's swap old GPU drivers with new ones. Remember ubuntu-drivers devices ? Use it again to find the driver you need.

$ ubuntu-drivers devices
== cpu-microcode.py ==
driver   : intel-microcode - distro non-free

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
vendor   : NVIDIA Corporation
modalias : pci:v000010DEd00001B80sv00003842sd00006180bc03sc00i00
driver   : xserver-xorg-video-nouveau - distro free builtin
driver   : nvidia-375 - third-party free recommended
driver   : nvidia-367 - third-party free

As you can see, nvidia-375 is newly recommended for the GTX 1080. Let's remove and replace the old driver.

# remove old driver
apt remove nvidia-367
apt autoremove

# install the new driver
apt install nvidia-375

# alternatively: have ubuntu auto-install necessary 3rd party drivers
ubuntu-drivers autoinstall

New GPU Driver Installed, Still Blank Screen

Temporarily Disable GPU Acceleration: Use the Grub boot option nomodeset to disable third-party graphics acceleration. You may add this during Grub boot by selecting "Advanced Boot Options" or by editing your Grub configuration in /etc/default/grub

# change this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# to this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

# OR, if you've followed my verbose boot recommendation. change this:
GRUB_CMDLINE_LINUX_DEFAULT=""
# to this:
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"

Apply these changes:

update-grub

Reboot. Your desktop environment should display something operable at this point.

Wrapping Up

I wanted to share these tips in the hopes of saving another soul valuable time. I hope these notes have been helpful to your experience performing a chipset or GPU upgrade on GNU/Linux. As always, Google is your friend.

If I have made a mistake or you have a correction to suggest, please detail it in the comments below.

Send feedback @msodrew