Solved freebsd-update upgrade -->> "Cannot identify running kernel"

Upgrading a 12.0-p5 to a 13.1 does not complete:

Code:
[root@vhost03 ~ (master #)]# freebsd-version
12.0-RELEASE-p5
[root@vhost03 ~ (master #)]# freebsd-update -r 13.1-RELEASE upgrade
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 2 mirrors found.
Fetching metadata signature for 12.0-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 3 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base world/doc world/lib32

The following components of FreeBSD do not seem to be installed:
kernel/generic-dbg world/base-dbg world/lib32-dbg

Does this look reasonable (y/n)? y

Fetching metadata signature for 13.1-RELEASE from update1.freebsd.org... done.
. . .
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
[root@vhost03 ~ (master #)]# /usr/sbin/freebsd-update install
src component not installed, skipped
Installing updates...
Kernel updates have been installed.  Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.
[root@vhost03 ~ (master #)]# shutdown -r now
Shutdown NOW!
shutdown: [pid 25353]
                                                                              
*** FINAL System shutdown message from root@vhost03.hamilton.harte-lyne.ca ***
                                                                             
System going down IMMEDIATELY                                                 
                                                                           
System shutdown time has arrived

This is an encrypted root-on-zfs system. Once the system is rebooted from the console the following is encountered:
Code:
[root@vhost03 ~ (master #)]# /usr/sbin/freebsd-update install
src component not installed, skipped
Cannot identify running kernel

So I go check for the kernel:
Code:
[root@vhost03 ~ (master #)]# sysctl -n kern.bootfile
/boot/kernel/kernel
[root@vhost03 ~ (master #)]# ls -l /boot/kernel/kernel
ls: /boot/kernel/kernel: No such file or directory
[root@vhost03 ~ (master #)]# ls -l /boot/kernel/*    
ls: /boot/kernel/*: No such file or directory
ls -l -d /boot/      
ls: /boot/: No such file or directory
[root@vhost03 ~ (master #)]# ls -l  /boot
lrwxr-xr-x  1 root  wheel  15 Mar 23  2019 /boot -> /bootpool/boot/
[root@vhost03 ~ (master #)]# ls -l  /bootpool/boot/
ls: /bootpool/boot/: No such file or directory
[root@vhost03 ~ (master #)]# ls -l  /bootpool/    
total 0
[root@vhost03 ~ (master #)]# ls -l -d /bootpool/
drwxr-xr-x  2 root  wheel  2 May 13  2016 /bootpool/

So, kern.bootfile points to a non-existent directory and file. So, which kernel is the system running?
Code:
[root@vhost03 ~ (master #)]# uname -a
FreeBSD vhost03.hamilton.harte-lyne.ca 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC  amd64

So, just where is the kernel?
<code>
[root@vhost03 ~ (master #)]# find / -name kernel
/usr/lib/debug/boot/kernel
</code>

I do not think that this is the one running, Just a guess but I suspect not.

So, just what is going on? More to the point, how is this fixed?

P.S.
I just love reading how other people have NEVER encountered a screw-up upgrading FreeBSD software. I guess I am plagued with uniquely bad luck.
 
Code:
[root@vhost03 ~ (master #)]# gpart list | grep boot
   label: gptboot1
   type: freebsd-boot
   label: boot1
   label: gptboot0
   type: freebsd-boot
   label: boot0
   label: gptboot2
   type: freebsd-boot
   label: boot2
   label: gptboot3
   type: freebsd-boot
   label: boot3
   type: bios-boot
   type: bios-boot

Code:
[root@vhost03 ~ (master #)]# gpart list | more
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 5860533134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   efimedia: HD(1,GPT,60da6e55-1954-11e6-a69b-0025907714e4,0x28,0x400)
   rawuuid: 60da6e55-1954-11e6-a69b-0025907714e4
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: gptboot1
   length: 524288
   offset: 20480
   type: freebsd-boot
   index: 1
   end: 1063
   start: 40

Well, I cannot seem to find any other file systems beyond what is listed below.
Code:
[root@vhost03 ~ (master #)]# ls -d -1 /*
/COPYRIGHT
/bin
/boot
/bootpool
/dev
/entropy
/etc
/home
/lib
/libexec
/media
/mnt
/net
/proc
/rescue
/root
/sbin
/sys
/tmp
/usr
/var
</code]
 
I said it was similar not identical - it may help you or give some pointers or if you look for other threads with identify in the titles you might find something.

I‘m one of the ones who has not yet had any issues with freebsd-update so don’t have any personal experience fixing update issues.
 
I have been unable to find anything which appears to handle this situation. I cannot find in kernel modules or bootcode anywhere on the running system.
 
I believe that this issue is resolved. It appears to be due to the fact that the first OS installed on this system was 9.x and that subsequent updates have changed how they handle things. In particular the soft-linked /boot was a problem for the freebsd-update detection code:

Code:
        # Figure out what directory contains the running kernel
        BOOTFILE=`sysctl -n kern.bootfile`
        KERNELDIR=${BOOTFILE%/kernel}
        if ! [ -d ${KERNELDIR} ]; then
                echo "Cannot identify running kernel"
                exit 1
        fi
[/CMD]

I the absence of any better idea I deleted the link /boot -> /bootpool/boot and created /boot/kernel.
freebsd-update install then completed. I have upgraded the packages and a reboot is in progress.

There must be a school for misleading error messages. The error is not as stated: "Cannot identify running kernel"; since uname -a gives that information. The error should be:"$KERNELDIR does not point to a directory" since that is what is being tested.
 
Last edited by a moderator:
Back
Top