LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to get kernel version from an image file (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-kernel-version-from-an-image-file-870906/)

sant_dcg 03-25-2011 05:04 AM

How to get kernel version from an image file
 
Hi,

I know that it is possible to get the kernel version from a running system using "uname" command.
I have a kernel image file in linux/arch/arm/boot/uImage.
Is it possible to get similar information from this image file? and how?

macemoneta 03-25-2011 06:38 AM

I'm not sure if it will work on an ARM image, but the file command works on x86/x86_64:

Code:

$ file vmlinuz
 
vmlinuz: Linux kernel x86 boot executable bzImage, version 2.6.38.1-6.fc15.x86_64 (mockbui, RO-rootFS, root_dev 0x902, swap_dev 0x3, Normal VGA


sant_dcg 03-25-2011 07:02 AM

@macemoneta: Thank you for the response. I tried this command, but it does not work as I expected.
I tried
$file uImage
$uImage: u-boot/PPCBoot image
What I expect is something like below:
$ uname -a
$ Linux 2.6.33.5-ptx-trunk #1 PREEMPT Wed Mar 16 14:40:18 CET 2011 armv5tejl GNU/Linux

This info is available in the image file, but I don't know how to extract it.

macemoneta 03-25-2011 07:47 AM

You need to update the '/etc/magic' or '/usr/share/misc/magic' (whichever exists on your system) with the displacements for the information. See man 5 magic. Once that's updated, the file command will be able to pull the information automatically.

Update: Google says you need:

Code:

# u-boot/PPCBoot image file
# From: Mark Brown <broonie@sirena.org.uk>
0        belong        0x27051956        u-boot/PPCBoot image
>4        string  PPCBoot
>>12        string  x                version %s


temp_sny 08-05-2011 06:12 AM

mkimage -l <uimage-name>
can tell u the kernel version

theNbomr 08-05-2011 01:48 PM

If the kernel image is compressed, you might be able to de-compress it first (but, as I recall, this is not as straightforward as you might expect). Otherwise, the strings command will find any strings of human-readable text in files of any description. It should be too hard to isolate the one that you're looking for.

--- rod.

jefro 08-05-2011 04:25 PM

Check crc against other kernels if worse comes to worse.


All times are GMT -5. The time now is 03:54 PM.