Find Linux kernel build date/time?
In a Linux distro, let’s say Ubuntu 14.04, how can one find the time and date when this particular Linux Kernel was compiled/built?
1 Answer 1
On Ubuntu, any other Linux distribution, and many other UNIX-based systems, you can use uname to find this information. You want uname -v for «kernel version information»:
$ uname -v #838 SMP Tue Feb 9 13:15:09 GMT 2016 $ uname -v Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 $ uname -v FreeBSD 10.2-RELEASE-p9 #0: Thu Jan 14 01:32:46 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC
Note that not all POSIX systems will show a build date as part of this output, or via uname at all (but Linux, BSD, and Mac OS will!).
The datestamp shown is the date/time when the kernel was compiled.
$ cat /proc/version Linux version 4.2.0-27-generic (buildd@lgw01-12) (gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) ) #32-Ubuntu SMP Fri Jan 22 04:49:08 UTC 2016
Based on discussion in the comments, and just to add additional information for others who may stumble across this, here’s how to get this information on a few other POSIX operating systems:
Use the oslevel command to display the AIX version, release, Technology Level (TL), Service Pack (SP) and build date. For example, this output shows AIX V6.1 Technology Level 8, Service Pack 1, built in the 45th week of 2012:
sh> oslevel -s 6100-08-01-1245
On Solaris, I can’t figure out a proper way to get a true compile date, but you can get the packaging date for the kernel (when the package was built) via pkg info kernel :
# pkg info kernel Name: system/kernel Summary: Core Kernel Description: Core operating system kernel, device drivers and other modules. Category: System/Core State: Installed Publisher: solaris Version: 0.5.11 Build Release: 5.11 Branch: 0.175.0.2.0.2.1 Packaging Date: Wed Oct 19 07:57:11 2011 Size: 17.99 MB FMRI: pkg://solaris/system/kernel@0.5.11,5.11-0.175.0.2.0.2.1: 20111128T20503
This one seem a bit tricker. You can get the link date (build date) of the kernel via:
echo "linkstamp?s" | adb /stand/vmunix
How to build kernel debug info as separate file?
When we share custom built kernel, It is common to give without debug info. Similar to sudo apt-get install linux-image-$(uname -r)-dbgsym , I would like to create separate debug info file for custom built kernel. Here and here they explained generally. I request to share knowledge on creating separate debug info file for entire linux kernel. For sample program
$ gcc -g calc.c $ ls -l total 16 -rwxrwxr-x 1 jeyaram jeyaram 8424 Apr 8 09:44 a.out -rw-rw-r-- 1 jeyaram jeyaram 246 Apr 8 09:32 calc.c $ objcopy --only-keep-debug a.out a.debug $ gcc calc.c -------------> compiling without debug info (skipped 'strip') $ ls -l total 20 -rwxrwxr-x 1 jeyaram jeyaram 4736 Apr 8 09:45 a.debug -rwxrwxr-x 1 jeyaram jeyaram 7200 Apr 8 09:52 a.out -rw-rw-r-- 1 jeyaram jeyaram 246 Apr 8 09:32 calc.c $ objcopy --add-gnu-debuglink=a.debug a.out $ gdb a.out GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: . Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.out. Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.debug. done. done.
$ objcopy --only-keep-debug vmlinux vmlinux.debug objcopy: Unable to recognise the format of the input file `vmlinux'