6

For this kernel version string (displayed on boot):

Linux version 3.12.18 (vagrant@vagrant-ubuntu-trusty-64) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #1 SMP Thu May 1 18:56:23 UTC 2014

How can the part in bold be removed or customized as part of the kernel build?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137

3 Answers3

4

You can customize parts of your version string you wish to edit (seen at boot or by invoking the command cat /proc/version) by setting the following defines:

  • KBUILD_BUILD_USER to change your "vagrant" value.
  • KBUILD_BUILD_HOST to change your "vagrant-ubuntu-trusty-64" value.

You may also be interested in KBUILD_BUILD_TIMESTAMP (changes "Thu May 1 18:56:23 UTC 2014") and KBUILD_BUILD_VERSION (changes "#1").


The complete Linux process banner is finalized in init/version.c. The values of these defines are generated by scripts/mkcompile_h. You could edit either of these files to have full control of your version string, but you never know when this additional information might be helpful; I would recommend only altering the defines. Another option is to make some changes your host system to override generated values. By doing this, you're adding additional build maintenance just to change a rarely queried value.

jdknight
  • 1,801
  • 32
  • 52
1

Kernel provides the below info only to user-space via uname call. You can seegcc version gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) only in customized uname binary/kernel.

man 2 uname

               struct utsname {
                   char sysname[];    /* Operating system name (e.g., "Linux") */
                   char nodename[];   /* Name within "some implementation-defined
                                         network" */
                   char release[];    /* Operating system release (e.g., "2.6.28") */
                   char version[];    /* Operating system version */
                   char machine[];    /* Hardware identifier */
               #ifdef _GNU_SOURCE
                   char domainname[]; /* NIS or YP domain name */
               #endif
               };

Fedora/Redhat does not display compiler information.

[root@Shash Sasi]# uname -a
Linux Shash 3.13.10-200.fc20.x86_64 #1 SMP Mon Apr 14 20:34:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

And vagrant@vagrant-ubuntu-trusty-64 looks like EXTRAVERSION is kernel main makefile.

VERSION = 3
PATCHLEVEL = 15
SUBLEVEL = 0
EXTRAVERSION = -rc3

In init/version.c:

const char linux_banner[] =
        "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
        LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";

const char linux_proc_banner[] =
        "%s version %s"
        " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
        " (" LINUX_COMPILER ") %s\n";

Also refer fs/proc/version.c

alk
  • 69,737
  • 10
  • 105
  • 255
Sasi V
  • 1,074
  • 9
  • 15
  • Sure, but this doesn't answer me how to change this. And remember I'm talking about the first line being output by the kernel on boot, not uname once the system has started. – Axel Fontaine May 02 '14 at 12:03
  • Modify Makefile to remove (vagrant@vagrant-ubuntu-trusty-64) and do check uname source on ubuntu to find where does it comes. I think If you compile vanilla kernel you wont see this. – Sasi V May 02 '14 at 12:40
  • My build is based on a clean download from kernel.org. EXTRAVERSION is empty, so this is not it. – Axel Fontaine May 02 '14 at 13:03
  • In init/version.c: const char linux_banner[] = "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; const char linux_proc_banner[] = "%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" " (" LINUX_COMPILER ") %s\n"; – Sasi V May 02 '14 at 14:52
  • @Axel: comment section is messy so I updated the answer. – Sasi V May 02 '14 at 14:53
0

It should be:

make menuconfig -> General setup -> Local version - append to kernel release

that is CONFIG_LOCALVERSION in the .config file.

Sigi
  • 4,826
  • 1
  • 19
  • 23