Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Switch from CentOS to Oracle Linux
# Switch from CentOS/Rocky Linux to Oracle Linux

This script is designed to automatically switch a CentOS instance to Oracle Linux
by removing any CentOS-specific packages or replacing them with the Oracle Linux
This script is designed to automatically switch a CentOS or Rocky Linux instance to Oracle Linux
by removing any distribution-specific packages or replacing them with the Oracle Linux
equivalent.

## Supported versions and architectures

This script currently supports switching CentOS Linux 6, CentOS Linux 7,
CentOS Linux 8, and Rocky Linux on both `x86_64` and `aarch64` architectures. It does **not** support CentOS Stream.
CentOS Linux 8, Rocky Linux 8 and Rocky Linux 9 on both `x86_64` and `aarch64` architectures.
It does **not** support CentOS Stream.

> Support for switching Rocky Linux should be considered **experimental** due to limited testing. Likewise, switching any of the
> operating systems mentioned above on `aarch64` hosts should be considered **experimental**.
Expand Down Expand Up @@ -44,7 +45,8 @@ any kernel that is installed that is _not_ provided by either the `base` or

## Usage

1. Login to your CentOS Linux 6, 7 or 8 instance as a user who has `sudo` privileges.
1. Login to your CentOS Linux 6, 7 or 8 or Rocky Linux 8 or 9 instance as a user
who has `sudo` privileges.
1. Either clone this repository or download the [`centos2ol.sh`][3] script.
1. Run `sudo bash centos2ol.sh` to switch your CentOS instance to Oracle Linux.

Expand Down Expand Up @@ -88,7 +90,7 @@ how to run them.

## Limitations

1. The script currently needs to be able communicate with the CentOS and Oracle
1. The script currently needs to be able communicate with the CentOS/Rocky and Oracle
Linux yum repositories either directly or via a proxy.
1. The script currently does not support instances that are registered to a
third-party management tool like Spacewalk, Foreman or Uyuni.
Expand Down
55 changes: 50 additions & 5 deletions centos2ol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ else
fi

case "$os_version" in
9*)
repo_file=public-yum-ol9.repo
new_releases=(oraclelinux-release oraclelinux-release-el9 redhat-release)
base_packages=("${base_packages[@]}" plymouth grub2 grubby)
;;
8*)
repo_file=public-yum-ol8.repo
new_releases=(oraclelinux-release oraclelinux-release-el8 redhat-release)
Expand Down Expand Up @@ -189,7 +194,7 @@ fi

echo "Checking for required python packages..."
case "$os_version" in
8*)
8* | 9* )
dep_check /usr/libexec/platform-python
;;
*)
Expand Down Expand Up @@ -238,7 +243,7 @@ fi

echo "Finding your repository directory..."
case "$os_version" in
8*)
8* | 9* )
reposdir=$(/usr/libexec/platform-python -c "
import dnf
import os
Expand All @@ -263,7 +268,7 @@ esac

echo "Learning which repositories are enabled..."
case "$os_version" in
8*)
8* | 9* )
enabled_repos=$(/usr/libexec/platform-python -c "
import dnf

Expand Down Expand Up @@ -294,6 +299,36 @@ cd "$reposdir"
# No https://yum.oracle.com/public-yum-ol8.repo file exists
# Download the content for 6 and 7 based systems and directly enter the content for 8 based systems
case "$os_version" in


9*)
cat > "switch-to-oraclelinux.repo" <<-'EOF'
[ol9_baseos_latest]
name=Oracle Linux 9 BaseOS Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol9_appstream]
name=Oracle Linux 9 Application Stream ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

EOF
if [ "$arch" == "x86_64" ]; then
cat >> "switch-to-oraclelinux.repo" <<-'EOF'
[ol9_UEKR7]
name=Latest Unbreakable Enterprise Kernel Release 7 for Oracle Linux $releasever ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL9/UEKR7/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
EOF
fi
;;
8*)
cat > "switch-to-oraclelinux.repo" <<-'EOF'
[ol8_baseos_latest]
Expand Down Expand Up @@ -358,7 +393,7 @@ if [[ $old_release =~ ^centos-release-8.* ]] || [[ $old_release =~ ^centos-linux
old_release=$(rpm -qa centos*repos)
fi
# Most distros keep their /etc/yum.repos.d content in the -release rpm. Rocky Linux 8 does not.
if [[ $old_release =~ ^rocky-release-8.* ]]; then
if [[ $old_release =~ ^rocky-release-*.* ]]; then
old_release=$(rpm -qa rocky*repos)
fi

Expand Down Expand Up @@ -443,6 +478,16 @@ case "$os_version" in
[centos-sclo-rh]="RPM oracle-softwarecollection-release-el7"
)
;;

9*)
declare -A repositories=(
[AppStream]="REPO ol9_appstream"
[appstream]="REPO ol9_appstream"
[BaseOS]="REPO ol9_baseos_latest"
[baseos]="REPO ol9_baseos_latest"
)
;;

8*)
declare -A repositories=(
[AppStream]="REPO ol8_appstream"
Expand Down Expand Up @@ -587,7 +632,7 @@ if [ "$arch" == "aarch64" ]; then
fi

case "$os_version" in
7* | 8*)
7* | 8* | 9* )
echo "Updating the GRUB2 bootloader."
if [ -d /sys/firmware/efi ]; then
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Expand Down