Rocky Linux 10 Tutorial / Migrate from Rocky Linux 9 with rollback checks

When moving from Rocky Linux 9 to 10, you prepare by installing a new Rocky Linux 10 server and migrating the necessary configurations and data. The Rocky Linux project does not officially support in-place upgrades between different major versions. By validating the new environment while keeping the existing server, it is easier to find issues before switching and to define rollback conditions.

Distinguish minor updates from a Rocky 9 to 10 migration

Updating to the latest minor version within 9.x and changing the major version from 9 to 10 are different tasks. The official Rocky Linux version migration document guides through a flow of fresh installation, preparing necessary accounts, repositories, packages, and restoring backups. Simply changing the numbers in the repository addresses or using dnf --releasever=10 is not considered a standard official migration method.

The purpose of preparing a new server is not to replicate the existing system as a whole. It is about adapting the data and settings required by the service on top of the default settings and security policies of the new operating system. Simply moving the old server's kernel, libraries, and RPMs to the new server may lead to mismatched dependencies and support scope.

Migration Target Tasks on the New Server Verification Criteria
User and Service Accounts Create the necessary accounts and define the corresponding UID and GID. The intended accounts must be able to read and write the migrated data.
Packages and Runtime Environment Install the required versions from the Rocky 10 repository. Programs and extension modules must work on the new runtime.
Configuration Reapply necessary changes based on the new default files. Configuration checks and service startup must succeed.
Files·DB Data Restore consistent backups to a separate path. Check content, permissions, and business functions together.
Access targets·Scheduled tasks Determine the conversion order and methods to prevent duplicate execution. User requests should go to the intended server, and tasks should be processed only once.

If a single device needs to be reinstalled, you cannot maintain the existing server at the same time, so it is more important to have external backups that have completed restore tests and means to return before reinstallation. If possible, practice first on a new VM or a separate server, and determine the downtime and failure criteria for the actual conversion.

Secure the required configuration list from the existing server

On the existing Rocky 9 server, first investigate the installation status and service dependencies. The following is an example of creating a new investigation directory from the administrator shell. Account lists and network configuration may contain operational information, so access should be restricted and not directly copied to public logs or posts.

sudo -i
set -euo pipefail
umask 077
test ! -e /root/migration-inventory
mkdir /root/migration-inventory
cd /root/migration-inventory
cat /etc/rocky-release > release.txt
getent passwd > users.txt
getent group > groups.txt
rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort > packages.txt
dnf repolist --enabled > repositories.txt
dnf module list --enabled > modules.txt
systemctl list-unit-files --state=enabled > enabled-units.txt
ss -lntup > listening-ports.txt
ip -br address > addresses.txt
ip route > routes.txt
exit

This list is not an installation script to be executed on the new server as is. It is a reference to select the items required for the service and to check the names, support availability, and alternative packages in Rocky 10. For services on Rocky 9 using module streams, it is particularly necessary to investigate the execution version and not assume that the choice can be directly transferred to the module command in Rocky 10.

For web and DB services, in addition to the data paths, check DB accounts and dump methods, uploaded files, external APIs, mail, storage, certificates, scheduled tasks, and backup tasks. Running the same scheduled tasks on both the new and existing servers simultaneously can result in duplicate mail sending or data processing. Operational passwords and secret keys should be delivered through separate protected procedures and should not be unnecessarily copied to files for configuration comparison.

Preparation of the new server and scope of practice

Install Rocky Linux 10 on the new server, perform updates, set up management accounts, check SSH access, and verify the firewall and SELinux basic settings first. If it is an x86-64 environment, also check the CPU requirements for Rocky 10. Do not assume that the new version's requirements are met just because the existing server is running Rocky 9.

When transferring an actual program, instead of copying the Python virtual environment or compiled extension modules directory as is, you recreate it on the new server using the runtime and dependencies supported there. For DB file formats and plugin compatibility, follow the migration procedures for each version of the product. Do not mix default settings and system files by overwriting /etc, /usr, and /var entirely on the new server.

The source lab moved a small read-only service from Rocky 9.8 container user space to Python on a Rocky 10.2 VM. Source Python was 3.9.25 and destination Python was 3.12.15. Both environments shared the Rocky 10 host kernel, so the test did not migrate a Rocky 9 kernel, boot process or systemd. A local address file simulated cutover and rollback without changing a production database or public DNS.

Run the exercise as regular user lfstudent and requires Podman, Python, tar, and curl. All UIDs and GIDs on the exercise VM are 1000. Build a separate image from the official docker.io/library/rockylinux image described in the Rocky Linux Podman guide. Actual production services must manage container lifecycles and effects of logout separately; here, the exercise is performed within the same login session from start to finish.

Preparing User Space on Rocky 9

Execute the commands in the shell of a dedicated Rocky 10 practice VM as a regular user, not on the existing server. Use a new path and a separate local image name. If you have existing practice materials, stop and first check the saved state.

set -euo pipefail
umask 077
test ! -e "$HOME/lf-course31"
mkdir -m 700 "$HOME/lf-course31"
cd "$HOME/lf-course31"
if podman image exists localhost/lf-course31-source9-updated:20261112; then
  printf 'The local lab image tag already exists. Stop and inspect it.\n' >&2
  exit 1
else
  image_status=$?
  test "$image_status" -eq 1
fi
podman pull docker.io/library/rockylinux:9
base=$(podman image inspect docker.io/library/rockylinux:9 \
  --format '{{index .RepoDigests 0}}')
printf '%s\n' "$base" > base.ref
printf 'FROM %s\nRUN dnf -y upgrade && dnf -y install python3 tar && dnf clean all\n' \
  "$base" > Containerfile
podman build --tag localhost/lf-course31-source9-updated:20261112 \
  --file Containerfile .
podman run --rm localhost/lf-course31-source9-updated:20261112 \
  /bin/bash -lc 'cat /etc/rocky-release; python3 --version; uname -r'

Do not assume the actual version just by looking at the tag. The :9 based image received in practice was labeled 9.3, and after a full 9-series update inside the source image, the lab confirmed 9.8 and Python 3.9.25. This update was done only within the isolated image. Record the digest of the base image in base.ref, noting that the same tag may later refer to a different image.

Inside a container, uname -r shows the kernel of the host Rocky 10. Confirm the operating system user space version using /etc/rocky-release or /etc/os-release, and distinguish it from the kernel version. Preparing the image or the first user mapping may take time, so do not repeatedly create containers with the same name. If interrupted, first check the actual state using podman ps -a and podman inspect.

Creating a read-only original service and migration backup

The following is a complete practice program that provides one setting and two JSON data files. /health represents the execution environment, and /items returns the data to be transferred. Write functions such as POST are not provided, and the original directory is also connected as read-only. In an actual write service, this part should be changed to maintenance mode and a final consistent backup procedure.

SOURCE_LISTENERS=$(ss -H -lnt 'sport = :18031')
TARGET_LISTENERS=$(ss -H -lnt 'sport = :18032')
test -z "$SOURCE_LISTENERS"
test -z "$TARGET_LISTENERS"
mkdir -m 700 source target
mkdir -m 700 source/data
printf '{"site":"LF31 migration lab"}\n' > source/config.json
printf '[{"id":1,"name":"alpha"},{"id":2,"name":"beta"}]\n' > source/data/items.json
cat > source/app.py <<'PY'
import json, platform, sys
from pathlib import Path
from http.server import BaseHTTPRequestHandler, HTTPServer
root = Path(sys.argv[1])
class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        try:
            if self.path == '/health':
                release = dict(line.split('=', 1) for line in
                    Path('/etc/os-release').read_text().splitlines() if '=' in line)
                data = {'os': release['VERSION_ID'].strip('"'),
                        'python': platform.python_version()}
            elif self.path == '/items':
                config = json.loads((root/'config.json').read_text())
                data = {'site': config['site'],
                        'items': json.loads((root/'data/items.json').read_text())}
            else:
                self.send_error(404)
                return
            body = (json.dumps(data, sort_keys=True) + '\n').encode()
            self.send_response(200)
            content_type = 'application/json'
        except (OSError, ValueError, KeyError):
            body = b'Cannot read migration data\n'
            self.send_response(500)
            content_type = 'text/plain; charset=utf-8'
        self.send_header('Content-Type', content_type)
        self.end_headers()
        self.wfile.write(body)
HTTPServer((sys.argv[2], int(sys.argv[3])), Handler).serve_forever()
PY
chmod 640 source/app.py source/config.json source/data/items.json
uid=$(id -u)
gid=$(id -g)
source_id=$(podman run -d --init --name lf-course31-source --label lf.course=31 \
  --userns=keep-id --user "$uid:$gid" \
  -p 127.0.0.1:18031:8080 -v "$PWD/source:/work:ro,Z" \
  localhost/lf-course31-source9-updated:20261112 \
  python3 /work/app.py /work 0.0.0.0 8080)
printf '%s\n' "$source_id" > source-container.id
sleep 2
podman exec "$source_id" id
curl --fail --silent --max-time 10 http://127.0.0.1:18031/health
curl --fail --silent --max-time 10 http://127.0.0.1:18031/items > source-response.json

--userns=keep-id allows a regular user's numeric ID to be maintained even inside the container. :ro,Z connects the original in read-only mode and applies a dedicated SELinux label. This label change is not applied broadly to public data directories. If the initial response fails, podman inspect "$source_id" and podman logs "$source_id" are checked, and verify the recorded container ID before resuming. The process does not proceed to the next step without checking the running original.

If the response and the original are confirmed to be normal, a relative path backup is created inside the container and copied to the host. The backup includes only this small program, settings, and data.

podman exec "$source_id" tar --numeric-owner -cpf /tmp/lf31-migration.tar -C /work .
podman cp "$source_id":/tmp/lf31-migration.tar backup.tar
sha256sum backup.tar > backup.tar.sha256
sha256sum -c backup.tar.sha256
tar --numeric-owner -tvf backup.tar

The checksum should be OK, and the file list should show app.py, config.json, and data/items.json. The standard tar backup in this example targets file contents and basic permissions. If you want to preserve ACLs and extended attributes, you should add checks for those options and attributes like the tutorial on backup and actual restoration verification for settings and user data . In particular, SELinux labels dedicated to containers should not be used as-is for the deployment policy of a new server.

Restoring on Rocky 10 and comparing the execution results

After checking again that the prepared target is empty, restore only the backup you created yourself. Since the restoration is done with the same general account on the same host, the numeric ownership mapping in this example is the same. If it is a different actual server, you need to first align the UID and GID of the new account or plan the necessary ownership conversions.

TARGET_ENTRIES=$(find target -mindepth 1 -print -quit)
test -z "$TARGET_ENTRIES"
sha256sum -c backup.tar.sha256
tar -xpf backup.tar -C target
python3 - <<'PY'
from pathlib import Path
import hashlib, stat
source, target = Path('source'), Path('target')
for p in sorted(source.rglob('*')):
    if not p.is_file():
        continue
    q = target/p.relative_to(source)
    if p.read_bytes() != q.read_bytes():
        raise SystemExit('FAIL: content differs')
    if (p.stat().st_uid != q.stat().st_uid or
        p.stat().st_gid != q.stat().st_gid or
        stat.S_IMODE(p.stat().st_mode) != stat.S_IMODE(q.stat().st_mode)):
        raise SystemExit('FAIL: owner or mode differs')
    print(p.relative_to(source), hashlib.sha256(q.read_bytes()).hexdigest())
print('PASS: file content, numeric ownership and modes match')
PY
python3 target/app.py "$PWD/target" 127.0.0.1 18032 > target-service.log 2>&1 &
target_pid=$!
sleep 1
curl --fail --silent --max-time 10 http://127.0.0.1:18032/health
curl --fail --silent --max-time 10 http://127.0.0.1:18032/items > target-response.json
cmp source-response.json target-response.json

If the contents and permissions of the three files are the same and cmp exits with status 0 without output, the data responses in this example match. On the destination /health, the new user space and runtime version appeared as follows.

{"os": "10.2", "python": "3.12.15"}

/items The response should include both alpha and beta and have the same site value. If the response is 500, check target-service.log, the file path, JSON syntax, and execution account permissions. This small server is for practice to verify functionality on the loopback and is not used as an external production web server.

Success in a small example does not mean that all dependencies of the actual service are compatible. In a production environment, login, view/write operations, file uploads, DB character sets and time zones, scheduled tasks, external integrations, certificates, and backup operations must be checked for each service. If possible, verify that the same results occur even after rebooting the new server, and check at the addresses and paths where users normally connect.

Test switching the connection target and rollback with the same data

In this exercise, client.url is a standard file that stores the address to send requests to. Without changing the public DNS or actual user traffic, you can observe the sequence from the existing environment→new environment→existing environment→new environment.

printf 'http://127.0.0.1:18031\n' > client.url
curl --fail --silent --max-time 10 "$(cat client.url)/health"
printf 'http://127.0.0.1:18032\n' > client.url
curl --fail --silent --max-time 10 "$(cat client.url)/health"
curl --fail --silent --max-time 10 "$(cat client.url)/items" | cmp - source-response.json
printf 'http://127.0.0.1:18031\n' > client.url
curl --fail --silent --max-time 10 "$(cat client.url)/health"
curl --fail --silent --max-time 10 "$(cat client.url)/items" | cmp - source-response.json
printf 'http://127.0.0.1:18032\n' > client.url
curl --fail --silent --max-time 10 "$(cat client.url)/items" | cmp - source-response.json

The source lab verified the origin 9.8/3.9.25, destination 10.2/3.12.15, and then the origin 9.8/3.9.25 again, and the response for each data was the same. Since the original was fixed as read-only and the new environment did not have write functionality, in this example, the comparison could revert only the connection target without needing to merge the data again.

In the actual write service, the data that enters the new server after the transition is crucial. If you only revert the address without reflecting this in the existing server, you could lose new orders, uploads, account changes, etc. Before migration, set the write suspension time, the final synchronization point, the conditions under which writing is allowed on the new server, and the method to retrieve data in case of rollback. Also, verify whether reverse restoration is possible between different DB versions.

Operational transition changes DNS, proxy/load balancer, or connection settings according to the chosen method. Due to DNS caching and existing connections, not all users move to the new server simultaneously. After the transition, observe error rates, logs, and key business checks, and do not resume writes or scheduled tasks redundantly on the existing server.

Clean up the lab and decide when to retire the old server

Only terminate the two processes started in the practice. target_pid and source_id below are targets started directly in the current session. If the session has been disconnected, check the saved container ID and the actual process/port to confirm it is the same target before cleanup, and do not terminate any other arbitrary Python processes.

kill "$target_pid"
wait "$target_pid" || test "$?" = 143
podman stop "$source_id"
podman inspect "$source_id" --format '{{.State.Status}} {{.State.ExitCode}}'
podman rm "$source_id"
ss -lnt 'sport = :18031'
ss -lnt 'sport = :18032'
sudo restorecon -RF "$HOME/lf-course31/source"
sha256sum -c backup.tar.sha256

--init places a small initial process in the container that is responsible for signal transmission, among other things. In a separate termination check applied to this, exited 143 appeared without a forced termination warning, and in this exercise, it was a termination state according to SIGTERM. It also checks whether both ports are closed and whether the backup checksum is OK. SELinux context restoration only applies to the original path of this exercise that the container has finished using, while retaining the content and default permissions.

The actual existing server is shut down after the new server has completed verification of business functions, operational access, backup and restoration, and scheduled tasks, and after meeting the established observation period and rollback conditions. Before shutdown, the location and method of restoring the last backup, differences in the configuration of the new server, and items that have not yet been verified are handed over. Judge migration completion by verified service behavior and data integrity, rather than by the date the new server was installed.