Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize or remove extra Linux kernel version details shown at boot?

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?

like image 409
Axel Fontaine Avatar asked May 02 '14 08:05

Axel Fontaine


Video Answer


2 Answers

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.

like image 98
jdknight Avatar answered Nov 03 '22 00:11

jdknight


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

like image 42
Sasi V Avatar answered Nov 02 '22 23:11

Sasi V