How to Use DNF5 System-Upgrade Command to Upgrade Fedora

With Fedora 41, the traditional dnf package manager was replaced by dnf5, introducing a faster and more efficient system for managing packages. Among its key features is the dnf5 system-upgrade plugin, which simplifies the process of upgrading to a newer Fedora release while ensuring improved performance and reliability.

This guide explains how to use the dnf5 system-upgrade command to upgrade Fedora seamlessly, with step-by-step instructions and troubleshooting tips.

What is dnf5 system-upgrade?

The dnf5 system-upgrade plugin is a powerful tool introduced in Fedora to streamline the process of upgrading from one Fedora release to another. It simplifies the upgrade by automating the download and installation of necessary packages and applying changes during a system reboot.

This plugin allows users to transition smoothly to a newer Fedora release without needing to reinstall the operating system manually. It handles complex tasks like dependency resolution, package replacements, and kernel upgrades, ensuring a seamless experience for users.

Key Benefits of Using dnf5 system-upgrade:

  • Efficient Process: Automatically downloads and installs all required updates for the target Fedora release.
  • Reduced Risks: Handles potential conflicts by providing options like --allowerasing to resolve package issues during the upgrade.
  • User-Friendly: Requires minimal user intervention, making it accessible for both new and experienced users.

The dnf5 system-upgrade plugin is an essential tool for Fedora users who want to keep their systems updated with the latest features, performance improvements, and security patches.

Pre-Upgrade Preparation

Preparation is essential to ensure a smooth and successful system upgrade. Follow these steps to ready your system:

Update Your Current System

Before starting the upgrade, make sure your system is fully up-to-date. This minimizes potential conflicts and ensures a stable starting point for the upgrade process. Run the following command to update all installed packages:

sudo dnf5 update --refresh

This command refreshes metadata and installs the latest versions of all available updates for your current Fedora release.

Back Up Important Data

System upgrades carry inherent risks, so it’s crucial to back up any important files or configurations. Use an external storage device or a reliable cloud service to safeguard your data. This precaution ensures you can recover your information in case of an unexpected issue during the upgrade.

Check System Requirements

Ensure your system meets the following requirements for a successful upgrade:

  • Stable Internet Connection: Upgrading requires downloading several packages, so a reliable connection is essential.
  • Sufficient Disk Space: Verify that your system has enough free space to accommodate the new packages. Use the command below to check disk usage:
df -h

If disk space is low, delete unnecessary files or transfer large files to external storage.

Disable Third-Party Repositories

Third-party repositories can sometimes cause conflicts during upgrades. Temporarily disable them with this command:

sudo dnf5 config-manager --set-disabled <repository_name>

After the upgrade is complete, you can re-enable these repositories to restore additional functionality.

Review Fedora Release Notes

Before proceeding, review the release notes for the Fedora version you’re upgrading to. Release notes provide critical information about new features, deprecated packages, and potential compatibility issues that might impact your setup. Visit Fedora’s official documentation for the latest release notes.

Pro Tip: Ensure your system is plugged into a stable power source during the upgrade to avoid interruptions, especially for laptops.

Using dnf5 system-upgrade

The dnf5 system-upgrade plugin simplifies upgrading Fedora by automating package downloads and applying the upgrade during a system reboot. Follow these steps to upgrade your Fedora system safely and efficiently:

Step 1: Install the dnf5-plugin-system-upgrade Package

First, install the dnf5-plugin-system-upgrade package, which provides the tools needed for upgrading your system:

sudo dnf5 install dnf5-plugin-system-upgrade

This command ensures the required plugin is available for managing the system upgrade process.

Step 2: Download the Upgrade Packages

Next, download all the necessary packages for the target Fedora release. Replace <target_version> with the Fedora version number you wish to upgrade to (e.g., 42):

sudo dnf5 system-upgrade download --releasever=<target_version>

If package conflicts occur, use the --allowerasing option to allow the removal of conflicting packages:

sudo dnf5 system-upgrade download --releasever=<target_version> --allowerasing

Adding the --allowerasing flag prevents the upgrade process from failing due to package conflicts.

Step 3: Reboot and Apply the Upgrade

After successfully downloading the upgrade packages, reboot your system to initiate the upgrade:

sudo dnf5 system-upgrade reboot

During the reboot, Fedora will enter a special mode to apply the downloaded packages and finalize the upgrade process. Allow the system to complete the upgrade before making any changes.

Pro Tip: Ensure your system has a stable power supply during this step to avoid interruptions. For laptops, keep the charger connected.

Post-Upgrade Steps

After completing the upgrade, it’s essential to verify the system, re-enable any previously disabled repositories, and clean up leftover files. Follow these steps to finalize the process:

Verify the Upgrade

Start by confirming that your system is running the upgraded Fedora version. Use the following command to check the current release:

cat /etc/os-release

This command displays the Fedora version and release information. If the version doesn’t match your target release, troubleshoot the upgrade logs or consider re-running the upgrade process.

Re-enable Disabled Repositories

If you disabled third-party or custom repositories during the upgrade, re-enable them to restore full system functionality:

sudo dnf5 config-manager --set-enabled <repository_name>

Clean Up the System

To ensure optimal performance and free up disk space, remove unused or obsolete packages and clear cached files:

  • Remove unnecessary packages:
sudo dnf5 autoremove
  • Clean up cached files:
sudo dnf5 clean all

This step helps maintain a tidy and efficient system after the upgrade.

Test Your Applications

Run your critical applications to verify that they work as expected. Pay special attention to any software with dependencies that may have been updated during the upgrade. If issues arise, consider reinstalling the affected application or checking the Fedora documentation for compatibility updates.

Pro Tip: If you use custom configurations or third-party software, check their compatibility with the new Fedora release to avoid disruptions in your workflow.

Troubleshooting Common Issues

Even with careful preparation, you may encounter issues during or after the system upgrade. Below are common problems and actionable solutions to address them.

Missing Dependencies or Package Conflicts

Package conflicts can occur if certain packages are incompatible with the target Fedora release. To resolve this, use the --allowerasing option when downloading the upgrade packages. This option allows conflicting packages to be replaced or removed automatically:

sudo dnf5 system-upgrade download --releasever=<target_version> --allowerasing

If the issue persists, review the error output to identify the conflicting packages. Uninstall them manually before retrying the upgrade.

Insufficient Disk Space

Running out of disk space is a frequent issue during upgrades. You can free up space by removing unused packages and clearing the package cache:

  • To remove unused packages:
sudo dnf5 autoremove
  • To clear cached package files:
sudo dnf5 clean packages

Additionally, check your current disk usage to identify large files or directories:

df -h

System Fails to Boot

If your system fails to boot after the upgrade, you can recover by booting into a previous kernel from the GRUB menu. Follow these steps:

  1. Restart your system and access the GRUB menu by holding the Shift key or tapping the Esc key during boot.
  2. Select an earlier kernel version from the list.

Once booted, check the system logs to identify the cause of the issue:

journalctl -xb

Preventative Tip: To minimize the risk of boot failures, ensure your kernel and critical system files are updated before starting the upgrade process:

sudo dnf5 update --refresh

Frequently Asked Questions

Can I skip multiple Fedora versions during an upgrade?

Skipping multiple versions is not supported. Fedora officially supports upgrading sequentially from one release to the next. Skipping versions can lead to unresolved dependencies or broken packages.

What happens if the upgrade process is interrupted?

If the upgrade is interrupted, you can safely reboot and re-run the dnf5 system-upgrade command. Fedora is designed to handle incomplete upgrades and will continue the process from where it left off.

Can I use dnf instead of dnf5 for system upgrades?

Starting with Fedora 41, dnf5 has replaced dnf as the default package manager. While dnf might still work for certain legacy operations, it is recommended to use dnf5 for all upgrades to ensure compatibility and reliability.

How do I resolve package conflicts during an upgrade?

If you encounter package conflicts, use the --allowerasing option when downloading upgrade packages. This allows conflicting packages to be removed during the process:
sudo dnf5 system-upgrade download --releasever=<target_version> --allowerasing

Can I test the upgrade process before applying it?

Although dnf5 does not natively support upgrade simulations, you can test the upgrade in a virtual machine or on a cloned environment to verify compatibility before performing it on your primary system.

What should I do if a specific repository causes errors?

If a repository causes errors during the upgrade process, disable it temporarily with:
sudo dnf5 config-manager --set-disabled <repository_name>
You can re-enable it after the upgrade is complete to verify its compatibility with the new release.

Can I apply only security updates during a system upgrade?

No, the dnf5 system-upgrade plugin performs a full-release upgrade. If you want to apply only security updates, use the following command within the same Fedora release:
sudo dnf5 upgrade --security

What should I do if the upgrade process seems stuck?

If the upgrade process appears stuck, first check your internet connection and system performance to ensure the delay is not temporary. If it remains unresponsive, press Ctrl+C to safely interrupt the process. You can then re-run the upgrade command using the same parameters to continue where it left off. Avoid forcibly restarting your system during the upgrade, as this may lead to incomplete installations or corruption. Once the download is complete, reboot your system to finalize the upgrade.

Conclusion

Using the dnf5 system-upgrade command is a straightforward and reliable way to upgrade your Fedora system to the latest release. This guide has provided a step-by-step approach to ensure a smooth process, from preparation to troubleshooting. By following these steps, you can take full advantage of the new features, performance enhancements, and security updates that Fedora has to offer.

Have you used the dnf5 system-upgrade command to upgrade Fedora? Share your experiences or tips to help other readers in the comments below!

Leave a Comment