• CentOS / AlmaLinux

Failed to switch root | OS tree | AlmaLinux

A CentOS 8.3 server has been migrated to AlmaLinux 8.3 using the script almalinux-deploy.sh. After rebooting the server was unreachable:

Apr 07 11:24:51 localhost systemd[1]: Starting Switch Root
Apr 07 11:24:51 localhost systemctl[740]: Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree

Grubenv

The file /boot/grub2/grubenv is mandatory for the boot process. It tells the kernel on which device/partition to find the root filesystem:

[root@centos8 ~]# cat /boot/grub2/grubenv
# GRUB Environment Block
saved_entry=fc12345f23af4a4d8ac468012345d4c1-4.18.0-240.15.1.el8_3.x86_64
kernelopts=root=/dev/md3 ro rd.auto crashkernel=auto vga=normal nomodeset net.ifnames=0 biosdevname=0 
boot_success=1

Grub config CentOS 8.3

With CentOS 8.3 there was a file called /boot/grub2/grubenv.rpmnew, that referred to ../efi/EFI/centos/grubenv via softlink:

[root@centos8 ~]# ls -l /boot/grub2
total 24
-rw-r--r--. 1 root root    0 Jan 22 13:29 device.map
drwxr-xr-x. 2 root root 1024 Jun 11  2020 fonts
-rw-r--r--. 1 root root 8923 Jan 22 15:58 grub.cfg
-rw-------. 1 root root 1024 Mar 24 20:48 grubenv
lrwxrwxrwx  1 root root   25 Sep  8  2020 grubenv.rpmnew -> ../efi/EFI/centos/grubenv
drwxr-xr-x. 2 root root 8192 Jun 11  2020 i386-pc

[root@centos8 ~]# ls -l /boot/efi/EFI/centos/grubenv
-rw-r--r--. 1 root root 1024 Mar 24 21:30 /boot/efi/EFI/centos/grubenv

Grub config AlmaLinux 8.3

While /boot/grub2/grubenv did exist on server centos8 as a plain file, it was redirected via softlink on server alma8. The path had been altered to ../efi/EFI/almalinux/grubenv during migration, but that file did not exist:

[root@alma8 ~]# ls -l /boot/grub2
total 19
drwxr-xr-x. 2 root root 1024 Oct 22  2019 fonts
-rw-r--r--  1 root root 6666 Apr  7 15:22 grub.cfg
lrwxrwxrwx  1 root root   28 Mar 15 19:28 grubenv -> ../efi/EFI/almalinux/grubenv
drwxr-xr-x. 2 root root 9216 Jan 26 16:04 i386-pc

[root@alma8 ~]# ls -l /boot/efi/EFI/almalinux/grubenv
ls: cannot access '/boot/efi/EFI/almalinux/grubenv': No such file or directory

The system cannot boot, it is missing the information where the root filesystem resides.

Check and repair boot files

Basically the migration from CentOS to AlmaLinux is smoothing using almalinux-deploy.sh. Before the final reboot we advise to check that all softlinks' targets in /boot do exist. Otherwise create them using CentOS files in /boot as a template.

Data protection info | Help us to optimize this site and allow cookies please - insights will not be passed on to third parties.
Decline Accept