Upgrade for centos/rocky linux to new major versions is not supported. If you look for it there are procedures, but the changes between major versions can be so siginificant that this is not a good idea. Therefore, an approach I often use is to upgrade by installing the newer version next to the current version. Of course, I have also paritioned my old system to separate my home directory and other important directory into separate partitions so that the upgrade does not require copying user files.
This has some risks, since you might lose connectivity to the old linux version if the upgrade fails. Therefore, I take several precautions when upgrading:
- install side by side: Install the new linux OS next to the old one. This will allow booting the old system if something goes wrong with the installation of the new system.
- make a full backup of the hard disk: Using a centos/rocky installation USB stick I create a full disk copy using dd
- partitioning: I partition my disk beforehand to allow multiple /boot and EFI partitions so that I can install linux distributions side by side. Also, at installation I separate basic OS (/) from other data such as user data (/home) and important applications (e.g. docker’s /var/lib/docker). This allows me to simply mount the user data of the old system in the new without having to copy data.
- rescue USB boot stick: I create a USB boot stick to allow booting the old OS even if all boot files of this OS are lost.
This post is about the last issue.
One problem that you encounter is that modern BIOSes no longer allow compatibility mode with a traditional boot sector and only support UEFI. Therefore, it is essential to create a UEFI USB boot stick. I reverse engineered the approach in this blog post from a linux installation.
UEFI booting
To boot from UEFI, a USB stick is required with 2 partitions:
- a linux partition: a linux partition using a supported filesystem, such as ext2, that contains the linux ramdisks and kernel images
- an EFI partition: this partition is loaded by the BIOS and contains a grub2 configuration that will load the partitions on the linux partition.
The EFI parition is created by copying a few files from the existing EFI installation of your linux system. These files will make the UEFI boot use grub2 to startup the system. Grub2 requires a grub.cfg which is also included on this partition. The grub2.cfg will startup linux using the kernel image, init ramdisk, and command-line options of the kernel that are located on the linux partition. See the code here.
How it (probably) works under the hood
Here is my understanding of how it all works:
-
- the BIOS finds EFI partitions through the special EF partition type
- it then executes the BOOTX64.EFI code, as I understand it BOOTX86.EFI supports secure boot.
- this in turn executes grubx64.efi which has the intelligence to load the grub configuration grub.cfg
- Grub itself does not understand FAT32 so it cannot load kernel images and ramdisks from the EFI partition, therefore it looks for the ext2 partition labeled RESCUE and mounts that as root using
search --no-floppy --set=root -l 'RESCUE'
- This then allows grub to access the images and kernels using paths relative to this root directory.
At least this is my understanding. Note that the procedure is relatively simple and much easier than previous approaches such as my earlier attempt using isolinux which has served me well for years. The UEFI boot basically does not require any special tools, although a similar approach could be used to automate the setup using the same configuration files as input.
Final thoughts
Creating a UEFI boot stick is quite easy, but it requires some effort to get to a minimal setup. A boot stick can be very useful to be able to still run your old linux installation when something fails during the upgrade. Generic tools won’t work when your kernel images and/or initial ramdisk are no longer present on your system. Using this setup it becomes easy to boot your linux system, even if the kernel and ramdisk images on your machine are lost. Thus it is an essential tool for rescuing your system.