How to Modify The Linux Kernel to Change The Version String That Uname Returns

How to change version string of the kernel?

At the top of the top-level Makefile, there are four lines

VERSION = 3
PATCHLEVEL = 18
SUBLEVEL = 7
EXTRAVERSION =

The values are different for different kernel versions, of course. These are used to construct the version string, so changing them before building the kernel changes the version string of the kernel you build.

Additionally, there's a configuration option CONFIG_LOCALVERSION, to be found under General Setup -> Local version - append to kernel release in make menuconfig that is appended to this.

Changing Version String in Linux Kernel sources

It's in the first four lines of the top level Makefile.

Adding some extra info in uname -v output string in linux kernel

The variable CONFIG_LOCALVERSION (inside your kernel .config file) let you set a custom string that will be appended to the kernel release number, thus shown when using 'uname'.

Is that what you want?

Kernel panic after changing version string

You made init segfault by breaking the kernel / user ABI for the uname(2) system call (by changing the struct size/layout).

Its exit code of 0xb is 11, which is the signal number for SIGSEGV. Attempted to kill init! was the cause of the panic, not a symptom or side-effect.

As @RossRidge said in a comment:

The 1024 number for _UTSNAME_LENGTH is only used for the stub implementation of uname for systems that don't support this system call. You'll need to rebuild glibc using your modified Linux kernel headers and then rebuild the init you're using with this custom version of glibc.

Dmitry confirms that changing _UTSNAME_LENGTH from 65 to 129 in

glibc-2.11.3/sysdeps/unix/sysv/linux/bits/utsname.h
solved the problem, after rebuilding the root fs.

A less-hacky general solution is to really rebuild glibc against the updated kernel headers.

Changing LineageOS build kernel version string

Easiest way is to temporarily rename your PC and create a new user.

Linux kernel : Kernel version string appended with either ''+ or -dirty

If Linux kernel images are being built with "-dirty" on the end of the version string, this simply means that modifications in the source directory have not been committed. Use git status to check for uncommitted files.

When you see the dirty string, it appends the kernel version string with the last abbreviated commit id + dirty to the kernel version.

You can use the above Git command to report modified, removed, or added files. You should commit those changes to the tree regardless of whether they will be saved, exported, or used. Once you commit the changes, you need to rebuild the kernel.

To force a pickup and commit of all such pending changes, enter the following:

 $ git add .
$ git commit -s -a -m "getting rid of -dirty"

Alternatively, use the make -j2 LOCALVERSION="-customstring" to get the custom string



Related Topics



Leave a reply



Submit