Migrate From Rocky Linux 8 To Rocky Linux 9 | Best Setup
In this guide, we’ll walk you through the process of How To Migrate From Rocky Linux 8 To Rocky Linux 9. Rocky Linux is a free, open, community enterprise operating system designed to be 100% bug-for-bug compatible with the leading upstream enterprise Linux distribution. Built by the community, for the community, it offers fully open and transparent development, providing ample opportunity for contributions.
The latest release, Rocky Linux 9, aligned with RHEL 9, was publicly released on July 14, 2022. This version boasts a range of impressive features and enhancements. Follow the steps outlined below on the Orcacore website to migrate from Rocky Linux 8 to Rocky Linux 9 using the command line.
Before you begin, ensure you’re logged into your Rocky Linux 8 system as a non-root user with sudo privileges. If you need assistance with this, refer to our guide on Initial Server Setup with Rocky Linux 8.
1. Check the Current OS and Version Available on Rocky Linux 8
First, update your local package index:
sudo dnf update -y
Next, verify your current operating system:
sudo cat /etc/os-release
[Output Example]
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="rocky-linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"

2. Backup Rocky Linux 8 System
Backing up your system before a major upgrade is crucial. Use tar
or your preferred backup solution. Store the backup on an external drive.
Using tar
, you can back up the entire system with this command:
sudo tar czf /rocky8.tar.gz
--exclude=/rocky8.tar.gz
--exclude=/dev
--exclude=/mnt
--exclude=/proc
--exclude=/sys
--exclude=/run
--exclude=/tmp
--exclude=/media
--exclude=/lost+found
/
This command creates a compressed archive of your entire file system, excluding certain directories like /dev
, /proc
, /sys
, and the backup archive itself, to prevent recursion.
3. Add Rocky Linux 9 Repositories
Add the Rocky Linux 9 repositories to your server. Check the official repo web path for the latest releases.
REPO_URL="https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r"
RELEASE_PKG="rocky-release-9.0-2.3.el9.noarch.rpm"
REPOS_PKG="rocky-repos-9.0-2.3.el9.noarch.rpm"
GPG_KEYS_PKG="rocky-gpg-keys-9.0-2.3.el9.noarch.rpm"
Install the packages:
sudo dnf install $REPO_URL/$RELEASE_PKG $REPO_URL/$REPOS_PKG $REPO_URL/$GPG_KEYS_PKG
4. Remove the RedHat-logos Directory
Remove the RedHat-logos directory to prevent upgrade failures:
sudo rm -rf /usr/share/redhat-logos
5. Upgrade Rocky Linux 8 To Rocky Linux 9
Now, upgrade Rocky Linux from 8.x to 9:
sudo dnf --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync -y
After the installation, rebuild the RPM database:
sudo rpm --rebuilddb
Reboot the system:
reboot
After logging in, verify the Rocky Linux 9 installation:
sudo cat /etc/os-release
[Output Example]
NAME="Rocky Linux"
VERSION="9.0 (Plow)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.0"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.0 (Plow)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="rocky-linux"
ROCKY_SUPPORT_PRODUCT_VERSION="9"
Conclusion
You’ve successfully learned to Migrate From Rocky Linux 8 to Rocky Linux 9. This upgrade enhances performance, security, and software compatibility.
Alternative Solutions for Migrating to Rocky Linux 9
While the distro-sync
method is a common and direct approach, here are two alternative methods for migrating from Rocky Linux 8 to Rocky Linux 9, each with its own considerations:
1. Using a Fresh Installation with Data Migration
This method involves performing a clean installation of Rocky Linux 9 and then migrating your data and configurations from the Rocky Linux 8 system. This approach ensures a clean system, free from potential issues lingering from the previous installation.
Explanation:
This method eliminates any potential conflicts or corrupted files that may exist in the current system. It’s particularly useful if you’ve experienced instability or suspect underlying issues with your Rocky Linux 8 installation. The key is to carefully plan the data migration to ensure no critical data is lost.
Steps:
-
Backup Data: This is the most crucial step. Use
tar
,rsync
, or your preferred backup tool to create a complete backup of your important data, configurations, and application data. Pay special attention to databases, website files, user home directories, and any custom configurations.sudo tar -czvf /mnt/backup/rocky8_data.tar.gz /home /etc /var/www /opt
This example backs up the
/home
,/etc
,/var/www
, and/opt
directories to a compressed archive namedrocky8_data.tar.gz
on the/mnt/backup
directory. Adjust the paths according to your system’s setup. -
Prepare Installation Media: Download the Rocky Linux 9 ISO image from the official Rocky Linux website and create a bootable USB drive or DVD.
-
Install Rocky Linux 9: Boot from the installation media and follow the on-screen instructions to perform a clean installation of Rocky Linux 9. Be sure to format the system partitions.
-
Migrate Data: After the installation is complete, boot into the new Rocky Linux 9 system. Mount the backup drive and restore your data. Carefully restore configuration files to their appropriate locations.
sudo mount /dev/sdb1 /mnt/backup # Assuming your backup drive is /dev/sdb1 sudo tar -xzvf /mnt/backup/rocky8_data.tar.gz -C /
This example mounts the backup drive and extracts the contents of the archive to the root directory (
/
). This will overwrite existing files, so ensure you’ve planned the restoration carefully. -
Reinstall Applications: Reinstall any applications that were not included in the data backup.
-
Verify: Thoroughly test your applications and configurations to ensure everything is working correctly.
Considerations:
- Requires downtime for the installation and data migration.
- More complex than the
distro-sync
method. - Provides a clean system, eliminating potential issues from the previous installation.
2. Using a Virtual Machine or Container for Testing
Before performing the upgrade on your production system, create a virtual machine (VM) or container running Rocky Linux 8. Clone your existing Rocky Linux 8 system into this environment and perform the upgrade within the isolated environment. This allows you to identify and resolve any potential issues without impacting your production system.
Explanation:
This approach allows you to test the upgrade process in a safe environment. You can experiment with different upgrade strategies and identify potential compatibility issues before committing to the upgrade on your primary system.
Steps:
-
Create a VM/Container: Use virtualization software like VirtualBox, VMware, or a containerization platform like Docker to create a new VM or container running Rocky Linux 8.
-
Clone the System: Clone your existing Rocky Linux 8 system into the VM/container. This can be done using disk imaging tools like
dd
or by using a backup and restore process.# Example using dd (WARNING: Incorrect usage can destroy data. Use with caution!) sudo dd if=/dev/sda of=/mnt/backup/rocky8.img bs=4096 conv=sync,noerror status=progress
This command creates a disk image of
/dev/sda
(your Rocky Linux 8 system drive) and saves it to/mnt/backup/rocky8.img
. This image can then be used to create a new VM. -
Perform the Upgrade: Within the VM/container, follow the steps outlined in the original article to upgrade from Rocky Linux 8 to Rocky Linux 9.
-
Test Thoroughly: After the upgrade, thoroughly test all your applications and configurations to ensure everything is working correctly.
-
Resolve Issues: If you encounter any issues, troubleshoot and resolve them within the VM/container. Document the solutions so you can apply them to your production system.
-
Apply to Production: Once you’re confident that the upgrade process is successful, apply the same steps to your production Rocky Linux 8 system.
Considerations:
- Requires resources to run a VM or container.
- Adds an extra layer of complexity to the upgrade process.
- Provides a safe environment for testing and troubleshooting.
By understanding these alternative methods, you can choose the approach that best suits your needs and resources when migrating from Rocky Linux 8 to Rocky Linux 9. Always remember to back up your data before undertaking any major system changes. The best way to migrate from Rocky Linux 8 to Rocky Linux 9 is the one that works best for you!