Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine the build/version of Linux kernel 'uImage'?

Tags:

linux-kernel

I'm trying to track down a kernel binary; is there a way to determine the version (build string) of a Linux 'uImage' binary?

Running

strings uImage

piped into various trailing grep statements leads me to think I'm dealing with a compressed image...

like image 356
Jamie Avatar asked Jul 05 '10 13:07

Jamie


People also ask

What is Linux kernel version?

The Linux® kernel is the main component of a Linux operating system (OS) and is the core interface between a computer's hardware and its processes. It communicates between the 2, managing resources as efficiently as possible.

What is the latest version of kernel?

Linux Kernel 5.19 Released With 7 New Features.


1 Answers

According to kernel's format specification, here's C code:

kver.c

#include <stdio.h>

int main(int argc, char** argv){
    if (argc > 1){
        FILE* f = fopen(argv[1], "r");
        short offset = 0;
        char str[128];
        if(f){
            fseek(f, 0x20E, SEEK_SET);
            fread(&offset, 2, 1, f);
            fseek(f, offset + 0x200, SEEK_SET);
            fread(str, 128, 1, f);
            str[127] = '\0';
            printf("%s\n", str);
            fclose(f);
            return 0;
        }else {
            return 2;
        }
    } else {
        printf("use: kver [kernel image file]\n");
        return 1;
    }
}

compile and run:

gcc -o kver kver.c
./kver /boot/vmlinux-something
like image 117
leon_pro Avatar answered Oct 04 '22 18:10

leon_pro