Fedora Linux Installation and Configuration

This guide covers the steps I perform when installing Fedora Workstation or Fedora Silverblue editions on my computers. I am using the x86_64 version of Fedora 35 in this guide. My computers use UEFI, some of them have Secure Boot enabled.

Updated
January 2, 2022
Previous versions
Fedora 32 Installation and Configuration
Fedora 28 Installation and Configuration
Fedora 24 Installation and Configuration
Fedora 22-23 Installation & Configuration

I believe everyone will find these notes valuable. I originally wrote this guide to suit my needs, but anyone else can find the information useful. Be careful with the commands presented in this document if you don't know what they mean, especially commands that begin with sudo. Recent versions of Fedora Linux are user-friendly out-of-the-box, so there is a chance that you won't need to apply any additional configuration at all. You proceed at your own risk.

When Upgrading: Clean Install vs. Upgrade

If you run a previous version of Fedora that is still supported, you can directly upgrade to the latest version. Gnome Software or dnf can be used to upgrade. In that case, find the official documentation. The Fedora Linux download page is a good starting point to get more information.

I prefer performing a clean installation each time a new version of Fedora is released, and this guide reflects this approach. Because I tend to store only the necessary minimum of data on my computers, it is not a problem for me to copy all my files to external storage, perform a clean installation, and copy my files back.

Backup Files and Configuration from the Previously-Installed Operating System

If you intend to replace an existing installation of the operating system, consider backing up all important data and collecting as much information about the installed software as possible.

The instructions in this section assume the previously installed operating system was Fedora Workstation, and you can skip these steps if you don't have anything to backup.

Backup Personal Files

Personal files of each user are located primarily in the /home/USERNAME directory.

List Installed Packages and Programs

List packages that were installed manually using DNF:

$ sudo dnf history list
$ sudo dnf history info ID
$ sudo dnf history userinstalled

List programs installed with Flatpak:

$ flatpak list --app

Some software may have been installed outside of the package manager (from a script, etc.). This may include Mathematica or Matlab. Therefore, also check other possible locations (e.g., /opt) to identify these programs.

Backup Virtual Machines

If you use virtual machines, consider backing up their configuration and data.

List virtual machines installed through virsh (or the virt-manager GUI):

$ sudo virsh list --all

Get the configuration of a virtual machine:

$ sudo virsh dumpxml VMNAME > VMNAME.xml

Backup all files mentioned in the exported configuration file. These might include:

To restore the virtual machine later, put the backed-up files in their correct location, and define the virtual machine from the configuration file:

$ sudo virsh define VMNAME.xml

Backup Podman and Toolbox Containers

Also make sure you don't have any important files stored in containers. These commands may be helpful:

$ podman container list --all
$ podman image list
$ toolbox

Download the Installation Media

After making sure all important data is backed up, we can move on to the installation of the new Fedora. Download the installation image of Fedora Workstation from the official Fedora download page, verify the SHA checksum, and follow their instructions to successfully create an installation drive from the image. More information on how to create the installation media can be found at a Fedora Docs page.

If you want an immutable system where the operating system is read-only and all regular applications are installed via Flatpak, you can try Fedora Silverblue instead of Fedora Workstation. Fedora Silverblue has a separate download page.

I usually use the dd tool to write the downloaded image to a USB flash drive. This command will overwrite data on the target drive, be careful!

$ sudo dd if="Fedora-Workstation-Live-x86_64-35-1.2.iso" of="/dev/USBDRIVE" bs=8M status=progress oflag=direct

It might also be helpful to see the Release Notes and the Installation Guide, both links are provided at the Fedora download page.

(Optional) Erase All Contents of the Hard Drive

First, boot up from the previously downloaded live media.

Next, make sure that LVM or Luks don't use the drive and that no partitions on the target drive are mounted:

$ lsblk

Delete the partitions:

$ sudo gdisk /dev/DRIVE

Get to the Expert mode, and zap all partition tables by entering:

  1. x
  2. z (answer y to both questions)

If installing on an SSD, it might also be a good idea to TRIM all of its space. The TRIM operation tells the SSD that all of the SSD capacity is unused. After this step, the SSD drive will most likely appear as empty with no partitions. Just issue one blkdiscard command, there's no need to Secure-Erase the drive under normal circumstances.

$ sudo blkdiscard -v /dev/DRIVE

Installation

The installation is straightforward. Use the default options so that the installer formats the whole storage drive and installs the Fedora Linux operating system.

If you want to install Fedora as a secondary operating system (dual boot), you may want to back up the contents of /boot/efi/EFI/Boot/ directory on your hard drive. It usually contains default boot files, which may be overwritten during Fedora installation.

Back when Fedora Workstation used LVM instead of BTRFS, the live media, by default, configured LVM and used the current "live" hostname as the name. To change LVM name, one could change the hostname just before proceeding with the installation:

$ hostnamectl set-hostname david-pc-fedora.localhost

After Installation

These are my recommended steps to do after the installation. Neither of them is required for Fedora to work, but they simplify my life.

Disable PackageKit

PackageKit and DNF apply only to Fedora Workstation and Server (and other Spins). Fedora Silverblue uses rpm-ostree and Flatpak instead.

My biggest annoyance with Fedora Workstation is its implementation of PackageKit, which is also used by Gnome Software. The situation is better today compared to the past when the DNF package manager recognized all software installed via Gnome Software us unneeded and wanted to remove it. But even today, Gnome Software (PackageKit) leaves unused dependencies upon package removal and seems to not share all of its metadata information with DNF. At the very least, PackageKit uses disk space by keeping its own cache for downloaded packages, which is separate from the cache used by DNF.

Free the package cache of PackageKit:

$ pkcon get-transactions
$ sudo pkcon refresh force -c -1
$ du -sh /var/cache/PackageKit/

Prevent PackageKit from ever starting again:

$ systemctl status packagekit.service
$ systemctl stop packagekit.service
$ systemctl disable packagekit.service
$ systemctl mask packagekit.service

From now on, use DNF instead. The following commands upgrade installed packages, install new packages, uninstall packages, check whether some system services need to be restarted after an update, and verify the integrity of installed packages.

$ sudo dnf --refresh upgrade
$ sudo dnf install PACKAGE
$ sudo dnf remove PACKAGE
$ sudo dnf needs-restarting
$ rpm -Va

Note that it is recommended to boot into a minimal environment, or at least log out of GNOME and switch to a non-graphical console (e.g., CTRL+ALT+F3), before running the dnf upgrade command to avoid possible program crashes caused by a modification of the program's files.

Install Updates

Install all available updates and reboot.

On Fedora Workstation (WARNING: better to do it in a console or a screen session as it modifies the running system):

$ sudo dnf --refresh upgrade

On Fedora Silverblue (safe to run anytime):

$ rpm-ostree upgrade

Finally, reboot to reload all software components (Workstation) or to boot to the new image (Silverblue):

$ systemctl reboot

Install Additional Packages

This is a list of some of the useful packages. This list does not contain regular apps like GIMP or Audacity (these apps have their own dedicated page on this website), but small system packages.

First, I will mention GUI system configuration tools. Some of them provide a nice interface to already installed command-line tools.

And finally, these are some of the console programs that I install the most often.

Useful package groups

There does not seem to be a way to install package groups on Fedora Silverblue yet. A toolbox instance can be used to list the group packages and then use rpm-ostree to install these individual packages.

To list available package groups, use the following command.

$ sudo dnf group list

The following command shows all possible groups.

$ sudo dnf group list -v hidden

I found the following package group useful for C/C++ programming and debugging.

$ sudo dnf group install 'C Development Tools and Libraries'

If you want to use virtualization, see Fedora docs.

$ sudo dnf install @virtualization

RPM Fusion Repositories

Besides some low-level firmware, Fedora doesn't ship with any other proprietary or non-free software. This includes some of the popular multimedia codecs, such as H.264 (Fedora used to ship even without MP3 music format support before the patents expired). RPM Fusion repository provides some of this software instead.

The up-to-date instructions to enable the RPM Fusion repository are on the RPM Fusion website.

Flatpak and Flathub Repository

Flatpak is the recommended way to install software on Fedora Silverblue. It is also a good idea to use it on Fedora Workstation. By default, Fedora comes with its own Flatpak repository enabled. But the main source for Flatpak apps, including proprietary software, is Flathub. The latest official instructions can be found on the Flatpak website. Note that there are also many other Flatpak repositories in existence.

The last time, I used:

$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
$ flatpak remote-add --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
$ flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
$ flatpak remote-add --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo

Snap

Snap is Ubuntu's alternative to Flatpak. The biggest difference from Flatpak is that there is a single repository which contains all Snaps, and that Snap may miss some important security features when used on Linux distributions other than Ubuntu. Here are official docs on how to setup Snap on Fedora.

Codecs

Fedora doesn't ship with non-free software. This includes many multimedia codecs. These are instructions to install the most important codecs for the usual video and audio playback. Up-to-date information can be found at RPM Fusion FAQ. RPM Fusion repositories must be enabled for this to work.

$ sudo dnf groupinstall multimedia
$ sudo dnf groupupdate multimedia

To install only OpenH264 codec without RPM Fusion, follow Fedora Wiki.

I also use some additional codecs for HEIF/HEVC, H.264, and H.265.

Better font rendering

Default font rendering on Fedora is now much better than it used to be a few years ago. Also, some software patents regarding subpixel font rendering have expired, so there is no longer a need to download the freetype-freeworld package from RPM Fusion. By default, Fedora uses Slight hinting and grayscale sub-pixel rendering.

To further improve the rendering, RGB sub-pixel rendering can be used. It improves the font readability on low-DPI screens, but it may cause colorful edges. It also looks terrible when the screen is rotated (when the sub-pixel RGB order changes).

$ gsettings set org.gnome.settings-daemon.plugins.xsettings antialiasing 'rgba'
$ gsettings set org.gnome.settings-daemon.plugins.xsettings hinting 'slight'
$ gsettings set org.gnome.settings-daemon.plugins.xsettings rgba-order 'rgb'
$ sudo ln -s /usr/share/fontconfig/conf.avail/10-hinting-slight.conf /etc/fonts/conf.d/
$ sudo ln -s /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/
$ sudo ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d/

I verified that the result exactly matches Ubuntu 20.04. Patches like freetype-freeworld are thus no longer needed. Pop!_OS 19.10 uses different settings than Ubuntu (grayscale).

Tips and Tricks

Some tips and hardware-specific problems are mentioned here.

Make Sure SSD TRIM is Enabled

Prior to Fedora 32, TRIM was not enabled by default. The user had to run one of the following commands to trim the free space on mounted SSD storage devices:

$ sudo fstrim -v --fstab
$ sudo fstrim -a -v

Fedora 32 enables the fstrim.timer service, which performs this operation automatically every week (other distributions have been doing this for years). To verify that TRIM is being issued automatically, run:

$ systemctl status fstrim.service

To check which storage devices support the TRIM (discard) operation, run the following command and check that the DISC-GRAN and DISC-MAX columns of the drive contain non-zero values.

$ lsblk -D

Disable Gnome automount

I don't like having all my unmounted drives automatically remounted after unlocking my screen after some time of inactivity. This may have been fixed, but it was super-annoying when I was doing a bitwise copy of a storage device, and it was automatically getting mounted mid-process.

$ gsettings set org.gnome.desktop.media-handling automount false

How to Update GRUB parameters (If Needed)

My old Sandy Bridge laptop has a strange feature: there is a non-existent monitor connected to one of the GPUs (probably the Nvidia one). This monitor can be disabled by passing a parameter to the GRUB command line. But Fedora seems to change the way to permanently modify these parameters with each new release.

Probably in Fedora 31, I used this command to add the video=VGA-2:d parameter:

# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) NEW_PARAMETER"
sudo grub2-editenv - set "$(sudo grub2-editenv - list | grep kernelopts) video=VGA-2:d"

On Fedora 32, I did a bit of research into this topic. It appears that there are at least three ways how to add an additional parameter to the GRUB command line.

The first option uses grubby-bls in the background (older, this may copy the cmdline arguments instead of using the kernel args variable):

$ sudo grubby --update-kernel=ALL --args="video=VGA-2:d"

The second option modifies the variable directly (probably preferred?):

$ sudo grub2-editenv - set "$(sudo grub2-editenv - list | grep '^kernelopts') video=VGA-2:d"

The third option should be equivalent to the second option, although I haven't tried it:

$ vi /etc/defaults/grub
$ grub2-mkconfig

The situation is very simple on Silverblue:

$ rpm-ostree kargs video=VGA-2:d

Enable TRIM on Silverblue when using LUKS

Fedora Workstation is configured to pass TRIM commands to the underlying device if full-disk encryption (LUKS) is used. This does not seem to be the case in Silverblue. I don't know whether this is a feature or a bug, but it can be enabled anyway.

$ rpm-ostree initramfs --enable --arg=-I --arg=/etc/crypttab

Verify:

$ lsinitrd /boot/ostree/fedora-885446f122734a39e9b9e600ce8fb0532d93d874c17db48c6676c55f3c447bd3/initramfs-5.3.7-301.fc31.x86_64.img | fgrep crypttab

An alternative, without having to re-generate initramfs on every rpm-ostree transaction:

$ rpm-ostree kargs --append rd.luks.options=c28fdfe4-ba7d-49bf-896f-5ffca011c39a=discard