Upgrading to a newer version of your Linux distribution is essential for staying secure, compatible, and supported. This article provides step-by-step instructions for upgrading outdated systems.
Important: Before performing any upgrade, back up important data and ensure your system has sufficient disk space and a reliable internet connection.
Home directories: Contains user files, configurations, and documents.
System configuration files: Stored in /etc, including server, networking, and user settings.
Databases: MySQL/MariaDB, PostgreSQL, etc.
Web or app data: Stored in /var/www, custom application folders, etc.
Custom scripts and services: Any non-default items in /usr/local, /opt, etc.
In the following scenario an external device has been previously mounted to the /mnt/ directory.
Back up home directories, databases, and configs:
sudo apt updatesudo apt install rsync
Example: backup /home and /etc to an external drive
sudo rsync -aAXv /home/ /mnt/backup/home/sudo rsync -aAXv /etc/ /mnt/backup/etc/
Optional: backup list of installed packages
dpkg --get-selections > package-list.txt
sudo dnf install rsync
Create backups
sudo rsync -aAXv /home/ /mnt/backup/home/sudo rsync -aAXv /etc/ /mnt/backup/etc/
List installed packages
rpm -qa > installed-packages.txt
sudo cp -r /etc/apt /mnt/backup/etc-aptsudo cp /etc/fstab /mnt/backup/
For server backups, include:
sudo yum install rsync # or dnf for newer versions
File and config backups
sudo rsync -aAXv /home/ /mnt/backup/home/sudo rsync -aAXv /etc/ /mnt/backup/etc/
MySQL/MariaDB dump
mysqldump -u root -p --all-databases > all-databases.sql
Store backups on a separate device, like an external drive or remote server.
Test your backups by restoring them in a virtual machine or test server if possible.
For critical systems, use tools that support incremental backups and encryption (like Borg or Restic).
Ubuntu allows upgrades only from one version to the next in sequential order. This means you cannot skip versions during the process. For example, to upgrade from 16.04 to 20.04, you must first upgrade to 18.04, and then from 18.04 to 20.04.
First, make sure to review the pre-upgrade checklist to properly prepare your server for a successful upgrade.
Once completed, you can proceed to the next step.
Ubuntu uses do-release-upgrade for version upgrades.
To begin the upgrade, run:
sudo do-release-upgrade
The system will perform some checks and present a pre-upgrade summary for your confirmation. During the process, you may be prompted to make decisions about certain packages (such as whether to upgrade, keep, or remove them).
At the end of the upgrade, you will be prompted to reboot your system. The upgrade is not considered complete until the system has been rebooted.
Make sure your system and installed packages are fully up-to-date before attempting a system upgrade to a new Fedora Linux release. Always back up your data, as upgrading is a potentially risky process, and you may need to restore the data in case of any issues.
To launch an upgrade, follow the next steps:
Upgrade the systemsudo dnf upgrade --refresh
Reboot the server
Download new release packages (replace 40 with the desired version)sudo dnf system-upgrade download --releasever=40
Reboot and start upgradesudo dnf system-upgrade reboot
Once the upgrade process completes, your system will reboot a second time into the updated release version of Fedora Linux.
Before starting the upgrade process, make sure to back up your data, as upgrading is a potentially risky process, and you may need to restore the data in case of any issues.
To update the Debian version, follow the next steps:
Step 1. First, ensure your system is up-to-date in its current release.sudo apt-get updatesudo apt-get upgradesudo apt-get full-upgrade
Step 2. In a text editor, replace the codename of your release with that of the next release in APT's package sources.
For instance, the line:
# deb https://deb.debian.org/debian/ buster main
should be replaced with:
# deb https://deb.debian.org/debian/ bullseye mainsudo nano /etc/apt/sources.list /etc/apt/sources.list.d/*
If you are migrating to Bookworm or later, then a new repo for non-free firmware is available.
If you wish, you can add non-free and non-free-firmware, depending on your specific needs.
For instance:
# deb https://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
or
# deb https://deb.debian.org/debian/ stable main contrib non-free non-free-firmware
Step 3. Clean and update package listssudo apt-get cleansudo apt-get update
Step 4. Perform the major release upgrade, removing packages if required:sudo apt-get upgradesudo apt-get full-upgrade
Step 5. Remove packages that are not required anymore. Be sure to review this list: you may want to keep some of them:sudo apt-get autoremove
Step 6. Reboot to make changes effective (optional, but recommended)sudo shutdown -r now
Now check the contents of /etc/debian_version and /etc/os-release and you should see info about the upgraded system.
These operating systems do not support in-place upgrades from one major version to another. To move to the next major version, you will need to perform a clean installation.
The full process includes the following steps:
Backup all relevant data that needs to be transferred to the new system.
This includes, but is not limited to:
- Custom user accounts (especially those manually created for specific purposes)
- Custom repositories
- Manually installed packages that should be reinstalled on the new system
- Website-related content
Be sure to identify all services the server is responsible for. This could include databases, mail servers, DNS configurations, and more. If you're unsure about what to back up, it's better to be safe and back up everything. You may also want to consult with a developer or system administrator to identify all critical data.
Save the backup to a secure location outside the current server.
Ensure that the backup is safely stored and accessible when you're ready to restore the data.
Reinstall the operating system with the desired newer version.
Restore the backup to the new system.
This typically involves:
- Recreating users and groups
- Restoring databases
- Re-uploading website files
- Reconfiguring DNS records and other services as needed