replace recompiled kernel module - linux-kernel

I edited the source of a kernel module, recompiled it and replaced it with the path from modinfo of the old kernel module, then I rebooted, there was no difference, my kernel module wasn't loaded, everything worked like i didn't changed the .ko file, although the file in the path (filename) of modinfo is the same file that I've recompiled.
when I grep my module from /boot/config-* it is configured as module (=m) and not built in to the kernel (=y)
How can I replace a kernel module?
Thanks.

Related

how to create a loadable kernel module .ko and make it part of a default linux image

I am trying to build a linux image using pengutronix. how to create a loadable kernel module .ko and make it part of a default linux image.
I have one of the kernel module as "<m>" there is no <*>(builtin) option for it .but i want to module to be part of the linux image, Ex) The .ko to be inside the /lib/modules folder.

Where is .config file is stored to make target linux image for a device

I am attempting to compile a custom linux kernel with target device drivers defined in .config file.
When I open Github i can see the .config file is in the master/blob
However, once I download the repository, I cant find that .config file, but when i compile using makefile, it selects right device drivers.
So where exactly is .config is located?
So where exactly is .config is located?
In the top-level directory of the kernel source; that is, the same directory from which you would issue the 'make' command to build the kernel.
Beware that the .config file is a hidden file; a filename that begins with a period is considered hidden.
Be sure you are using the proper commands/tools that would show all files in a directory.

How do I get a Linux kernel binary file?

I have downloaded the latest kernel from kernel.org . What I want is to compile it to get the executable file. I need the file to run some commands on it (like strings) to figure what how to identify the linux kernel from its binary file.
All the tutorials on the internet are for upgrading/changing the kernel but I only want the binary file.
I think what you want are vmlinux and *.ko elf files, but you must compile your kernel first. The bzImage is compressed so you cannot run strings on it.

Missing headers for kernel in bzImage loaded on qemu

I am trying to compile a kernel module of kernel version 3.2.0 on a linux kernel bzImage loaded on a qemu emulator, however I am getting the following error:
/lib/modules/3.2.0/build no such file or directory. I tried to look up solutions over the net but nothing specific related to solve this for a kernel image being loaded over qemu. The command I issue to load the bzImage on qemu is qemu/qemu-system-x86_64 -m 2G -kernel ../linuxkernel/arch/x86/boot/bzImage -hda ../../sid.ext2 -append "root=/dev/sda"
bzImage only contain kernel's image, it doesn't contain files needed for build modules.
You should:
Find kernel headers(with some files built), corresponded to you kernel, and install them to directory, to which /lib/modules/3.2.0/build points.
Or build kernel from the sources by hands. In that case reference /lib/modules/<kernel-version>/build will point to your compiled source files automatically.

How to extract kernel headers for compiling kernel module later

I compiled various Linux kernel from git repositories. There are times when I copied the kernel to other system and need the kernel header to compile external module.
I tried to run "make headers_install" but it only generated a include/ folder. When I tried to point external module to that folder, it complains it cannot find Makefile.
What is the proper way to package kernel-header for deployment?
Thanks.
Create kernel packages instead, that's "make deb-pkg" for dpkg based distros and "make rpm-pkg" for RPM based ones. These create multiple packages, one of those is a package usable for external modules building. That should be linux-headers-* for the Debian packages and a "devel" package for he RPM versions.
In some ways this is just an expansion of the previous answer. If you look at the file scripts/package/builddeb in the kernel sources you will find script code which selects the files needed for building external modules from a kernel build and puts them into /usr/src/linux-headers-$version. I can find that script code in my local kernel version by searching for the string "# Build kernel header package" in the builddeb file. If you want to do things by hand you could execute that script code manually.

Resources