Don't Add "+" to Linux Kernel Version

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

Unable to install a kernel even though it compiled successfully

You might have successfully installed a different kernel version, but in order to boot into it, you need to tell the bootloader to do so.

I'm going to assume that you are using GRUB2 as bootloader, since it's standard on most distributions including Ubuntu. In order to boot the new kernel, you have multiple options.

Option 1

This is the safest and recommended option.

  1. Edit the GRUB configuration file /etc/default/grub (you need to be root, so use something like sudo vi or sudo nano) and make sure that you have GRUB_TIMEOUT=N where N is a number of seconds. If you don't, then just add it in a new line. You want N to be at least 5 or 10 so that you have time to select the correct kernel version when GRUB starts.

    Additionally, make sure that you do not have any of the following lines (you shouldn't have them, but if you do, remove or comment them):

    GRUB_DISABLE_RECOVERY="true"
    GRUB_DISABLE_SUBMENU=y
    GRUB_HIDDEN_TIMEOUT=N
    GRUB_TIMEOUT_STYLE=hidden
  2. Save the changes to /etc/default/grub and run sudo update-grub. This will detect currently installed kernels and add them to the bootable list when you start the computer and enter GRUB.

  3. Reboot your PC, when GRUB starts you will see a list of options. If you don't do anything, your default kernel will boot, otherwise you can use the arrow keys and the ENTER key to navigate to "Advanced options for Ubuntu", where you will find the list of available kernels and you will be able to select the one you prefer.

    It should look something like this:

    grub1

    grub2

Option 2

Use only as fallback if option 1 does not work (it should, but you never know). This is not as clean as option 1 because it changes the default kernel, and changes are also probably going to be overridden by an upgrade of your current kernel (which technically does exactly this to update the default version).

  1. Make the kernel you want the default one by changing the two symlinks /initrd.img and /vmilunuz to point to the right versions of the kernel and initrd image. This can be done either manually or through the linux-update-symlinks command.

    $ linux-version list --paths
    ... grab the correct VERSION and PATH ...

    $ sudo linux-update-symlinks install VERSION PATH
  2. Run sudo update-grub to let GRUB detect the changes.

  3. Reboot your PC.

Option 3

Manually boot into the kernel you want from the GRUB command line. This is an advanced option and I'm listing it only as a last resort, you should never need to do this unless you have completely broken your system configuration.

  1. Reboot the PC into GRUB, and as soon as you see it, press C to enter the GRUB command line.
  2. Follow this answer from now on.

In any case, remember that playing around with kernel development on your own machine is not a good idea if you are not sure what you are doing. I recommend you use a virtual machine to experiment with the kernel, that way if anything goes wrong you can just throw it away and create a new one.

YOCTO : can't insert linux module to the kernel : versions are different

The module is not compiled with the same version as your kernel (on the embedded device).

You need to simply compile the module with the right kernel.

You will need to find your kernel recipe in the meta of Yocto, download it (reset the repository of the downloaded kernel to the SRCREV of the recipe), then build your module.

Installing Linux Kernel Modules without plus + (on ARM)

this worked for me:

sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" .config && make LOCALVERSION=

Why do we have to use another kernel source from the Internet when implementing a new system call?


I'm trying to add a system call to my OS and when I read the online tutorials, it always starts with downloading and extracting a kernel source code from the Internet.

Well, that's right. You need to modify the kernel source code in order to implement a new syscall.

why do we have to use another kernel source from the Internet?

It's not "another kernel source", it's just "a kernel source". You don't usually have the source code for your currently installed kernel already at hand.

Normally, most Linux distributions provide a binary package for the kernel itself (which is automatically installed), a package for its headers only (which can be used to compile new modules), and possibly a source package related the binary package.

For example, on Ubuntu or Debian (assuming that you have enabled source packages) you should be able to get the current kernel source:

apt-get source linux-image-$(uname -r)

Since the tutorial author cannot possibly know which kernel version or which Linux distribution you are using, or even if your distribution provides a kernel source package at all, they just tell you to download a kernel source package from that Linux kernel website. This also ensures you use the exact same version that is shown in the tutorial, to avoid any compatibility problem with newer/older kernel versions.

Furthermore, you usually don't want to play around with the kernel of the machine you are using, since if something bad happens, you can end up damaging your system. You usually want to use a virtual machine for experimenting.

Can we add the new system call to the running OS and compile it directly?

Not really, it's not possible to hot-patch a new syscall into a running kernel. Since you need to modify the source code, first of all you need to have the source. Secondly, you'll need to do whatever modification you need and then compile the new kernel. Thirdly, you'll need to properly install the new kernel and reboot the machine.



Related Topics



Leave a reply



Submit