Operating System - HP-UX
1833184 Members
3253 Online
110051 Solutions
New Discussion

how to tell which file is the kernel that is running

 
SOLVED
Go to solution
curt larson_1
Honored Contributor

how to tell which file is the kernel that is running

how can I find out what is the file name of the current running kernel, ie vmunix or vmunix.prev or ??
26 REPLIES 26
Paul Sperry
Honored Contributor

Re: how to tell which file is the kernel that is running

the default is vmunix
Paul Sperry
Honored Contributor

Re: how to tell which file is the kernel that is running

the default is vmunix
Jeff Schussele
Honored Contributor

Re: how to tell which file is the kernel that is running

Hi curt,

Not 100% positive, but I believe if you look at the VERY top of the current /var/adm/syslog/syslog.log file, all the device discovery entries should be prefaced by date, time, hostname & then *kernel* name.
It's been forever since I booted an alternate kernel. But a quick test on a sandbox system ought to prove/disprove it.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

yes i know the default is vmunix and the default backup kernel is vmunix.prev and the kernel has to be in the first file system of the boot disk and lifcp rDiskDevFile:AUTO - will give me the autoboot string.

But if you weren't there when the system booted, how do you know what the file name is for the kernel that is currently running?
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

Jeff,

I'm using a workstation on 11.0 and it is booted from the default kernel (/stand/vmunix). But, syslog doesn't contain anything about the file name of the kernel that is running. unless nothing is written to the log file if the default file name is used for the kernel.
John Poff
Honored Contributor

Re: how to tell which file is the kernel that is running

Hi,

I'm looking in syslog on one of our boxes and it looks like it wrote 'vmunix' when it started booting:

Jun 4 20:13:47 dd01 syslogd: restart
Jun 4 20:13:47 dd01 vmunix: gate64: sysvec_vaddr = 0xc0002000 for 2 pages
Jun 4 20:13:47 dd01 vmunix: NOTICE: autofs_link(): File system was registered at index 3.
Jun 4 20:13:47 dd01 vmunix: NOTICE: cachefs_link(): File system was registered at index 5.
Jun 4 20:13:47 dd01 vmunix: NOTICE: nfs3_link(): File system was registered at index 6.
Jun 4 20:13:47 dd01 vmunix: 0 sba
Jun 4 20:13:47 dd01 vmunix: 0/0 lba
Jun 4 20:13:47 dd01 vmunix: 0/0/0/0 btlan
[etc.]

JP
Jeff Schussele
Honored Contributor

Re: how to tell which file is the kernel that is running

Hi (again) curt,

Well it was worth a shot. I just tested that on a workstation by copying /stand/vmunix to /stand/vmunix.safe, rebooted interrupted the boot & entered @ the ISL> hpux /stand/vmunix.safe
Other than a message in syslog.log that I didn't have a DLKM.safe all the entries were STILL prefaced by vmunix:

I'm sure there's a way, I'll keep digging. I suspect that something ought to be able to tell you.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Patrick Wallek
Honored Contributor

Re: how to tell which file is the kernel that is running

If you weren't there when the system was booted, and no one intereacted with the boot to force /stand/vmunix.prev, then the system booted with /stand/vmunix.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: how to tell which file is the kernel that is running

Try this:

echo "boot_string/s" | adb -k /stand/vmunix /dev/kmem

/stand/vmunix should be in the output but if not, the kernel file, /stand/umunix does NOT match the core image, /dev/kmem so the command should be repeated replacing /stand/vmunix with another kernel file,usually /stand/vmunix.prev.
If it ain't broke, I can fix that.
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

John,

vmunix in this situation, just means that the message was logged by the kernel. The message will contain vmunix no matter which file was booted from.
Caesar_3
Esteemed Contributor

Re: how to tell which file is the kernel that is running

Hello!

You can check the dmesg to find out!

Caesar
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

as always, Mr. Stephenson has an answer that works.

situation is:

/stand/vm is a copy of /stand/vmunix. /stand/vmunix.prev is different from /stand/vmunix even though it is the same size.

boot with /stand/vm as the kernel, clay's solution
using adb -k /stand/vm /dev/kmem correctly reports /stand/vm as the bootfile.
using adb -k /stand/vmunix /dev/kmem also correctly reports /stand/vm as the bootfile.
and using adb - /stand/vmunix.prev /dev/kmem doesn't report anything as the boot string. ie bootstring:
with no value.

I'm going to hold off on awarding the big points in the hope there will be an alternative solution.

Because, the reason for wanting to know which file is the kernel is so I can use that file as an argument for the adb command. And, clay's solution is to test all the possible kernels till one works. This seems more of a brute force type of solution.

although in reality, it isn't all that bad. after all how often aren't you using vmunix or vmunix.prev. and only in that case would I need to test all the large (>6M) files in /stand, which shouldn't be all that many.

thanks clay
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

Caesar,

the kernel file name isn't reported within dmesg on my system.
A. Clay Stephenson
Acclaimed Contributor

Re: how to tell which file is the kernel that is running

Any copy of /stand/vmunix will work BUT it's really /dev/kmem that has the actual data - and it's always correct. The file argument simply supplies adb with the correct data offset information so that adb knows where to look within /dev/kmem. If you get a valid boot string using any file then that's your boy because again, it's /dev/kmem that's really supplying the data.

Dmesg should never be relied upon because once it's circular buffer fills, it begins to overwrite itself.
If it ain't broke, I can fix that.
Paul Sperry
Honored Contributor

Re: how to tell which file is the kernel that is running

NAME
kmpath - retrieve kernel name and associated kernel component set
information

SYNOPSIS
/usr/sbin/kmpath [-k]
/usr/sbin/kmpath -c [kernel_name]
/usr/sbin/kmpath -i [kernel_name]

DESCRIPTION
kmpath retrieves the main kernel file name and path information of the
currently running kernel. kmpath also retrieves the Kernel ID String
(KIS) and the associated /stand/dlkm.KIS directory of the current or
specified kernel.

Each kernel is composed of several distributed component files, the
kernel component set, which use a defined naming convention, and are
all required for a kernel to boot and run properly. During the
process of configuring a new kernel, a unique Kernel ID String (KIS)
is embedded into the kernel image. The main kernel file (by default
/stand/vmunix) is associated to its component files via the KIS. The
/stand/dlkm.KIS directory contains several of the kernel component set
files used by the DLKM infrastructure, including dynamically loadable
kernel module images.

If no options are specified, kmpath returns the full path of the main
kernel file of the currently running kernel, which constitutes the
boot kernel path of the currently booted kernel (for example,
/stand/vmunix).

Options
The kmpath options have the following meanings:

-k Return the base name of the main kernel file of the currently
running kernel (for example, vmunix).

-c [kernel_name]
Return the /stand/dlkm.KIS directory name. If kernel_name is not
specified, KIS corresponds to the currently running kernel's
Kernel ID String. If kernel_name is specified, KIS corresponds
to the specified kernel's KIS.

-i [kernel_name]
If a kernel_name is not specified, return the KIS of the
currently running kernel. If a kernel_name is specified, return
the KIS associated with the specified kernel.

FILES
/stand/kernel_name Main kernel file.

Hewlett-Packard Company - 1 - HP-UX 11i Version 1.6: Feb 2002

kmpath(1m) kmpath(1m)

/stand/dlkm.KIS Directory containing DLKM-related elements of
the kernel component set. (KIS is the Kernel
ID string in the corresponding kernel image).

/stand/krs/KIS.p0 Kernel-specific kernel registry file. Element
of the kernel component set that contains
kernel-specific configuration data persistent
across system reboot. (KIS is the Kernel ID
string in the corresponding kernel image).

/stand/boot.KIS Directory that contains links to the files in
the kernel component set that are required by
the boot loader during the process of booting a
kernel with Kernel ID String KIS.

Paul Sperry
Honored Contributor

Re: how to tell which file is the kernel that is running

# /usr/sbin/kmpath -k
vmunix
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

Paul,

your getting closer. but while kmpath exists on my 11.0 system, it doesn't return anything.
Bill Hassell
Honored Contributor

Re: how to tell which file is the kernel that is running

Try kmpath without the -k for 11.0 systems, ie, just kmpath.


Bill Hassell, sysadmin
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

Bill,

/usr/sbin/kmpath
/usr/sbin/kmpath -k
/usr/sbin/kmpath -c
all return the same thing, the shell prompt. on my system -i is an illegal option and there is no man page.
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

a short script using clay's suggestion

#!/usr/bin/ksh

kernel=""
for i in $(find /stand -xdev -type f -size +12000 -print )
do
kernel=$(
echo boot_string/s |
adb -k $i /dev/kmem |
awk '{
if ( $0 ~ "/stand" ) {
a=match($0,"/stand");
b=substr($0,a);
print b;exit;}
}')
if [[ -n "$kernel" ]] ;then
break
fi
done
print "$kernel"

and one using another method

#!/usr/bin/ksh

/usr/sam/lbin/getkinfo -b

cat /var/sam/bot.config |
awk '/Kernel_Path/ {
while ( $1 != "string" ) getline;
split($0,a,"\"");
print a[2];
exit;
}'
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

a bit of a typo there, it should be
cat /var/sam/boot.config
Massimo Bianchi
Honored Contributor

Re: how to tell which file is the kernel that is running

Hi,
i have an alternative solution.

And if you get ther running kernel configuration? I will attacha short procedure at the bottom.

The idea is to extract (at low cost) the parameters from the running kernel.
Then you can compare (diff) the result either with /stand/system or with /stand/system.prev or whichever system file!

It's just a check with smaller files...



11.x

1. Change directories to /stand/build.
cd /stand/build

2. Create a new system file from the running kernel.
/usr/lbin/sysadm/system_prep -s /stand/build/system


HTH,
Massimo
Bill Hassell
Honored Contributor

Re: how to tell which file is the kernel that is running

Check your version of kmpath:

# what /usr/sbin/kmpath
/usr/sbin/kmpath:
$Revision: 82.20 $

There is no man page for kmpath at 11.0 but I'm not sure whether that means it's not meant to be a supported command. Normally, 'backend' commands are stored in /usr/lbin (or for sam, /usr/sam/lbin) and with a few exceptions, no man pages.


Bill Hassell, sysadmin
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

thanks for the reply bill

yes i'm using the absolute pathname /usr/sbin/kmpath.

yes what returns:
$Revision: 82.20 $

and i did look for possible patchs for kmpath but a seach didn't return any for 11.0 or 11.11