Build package from source
As a kernel dev, I would build and install kernel from source. After doing so, we need to reinstall linux-header and linux-image for systemtap to work with the correct kernel version.
This is a kind of struggling to me again.
The step I found is a little tricky. Maybe there is a better way, while I just managed to do this in the following steps. If you have a better way, I'd appreciate it a lot.
The general idea is get from kernel make target deb-pkg and the document in Ubuntu wiki -- Systemtap.
I am curious about why the deb-pkg target doesn't work as it should. And the first steps in Ubuntu wiki -- Systemtap doesn't function on my machine. Maybe I missed some critical steps in both parts.
The good news is I managed to combine the first part in deb-pkg and the last part in Ubuntu wiki -- Systemtap, and finally get the package I need.
Kernel Build Tip
To use systemtap with kernel, you need to make sure kernel built with following configurations.
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_REDUCED=n
CONFIG_KPROBES=y
CONFIG_RELAY=y
CONFIG_DEBUG_FS=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
And one more tip not recorded in document -- a modification in Makefile. If not modified, some functions will not get proper context variables.
Create Rules
The first step is to run
in kernel source directory. I named this "create rules", since this creates config files in debian directory.
Before running make deb-pkg, we need to make some modification as below.
Here is the reason for those changes. You could skip it if you don't want to know the detail now.
First we comment out "make clean" to forbid rebuild the kernel again. As you know, each time to rebuild the whole kernel will take a huge amount of time.
Second we comment out the "dpkg-buildpackage" command. I didn't manage to run this command.
Third we remote the "make clean" in debian/rules. Since in next step, the command will first call the clean rule and then rebuild. If you don't want to waste too much time, remove it.
Create Package
After the previous step, we may get debian directory in kernel source code and a tar file of the source tree.
Now it is time to run the following command to get the package we want.
Those packages are in parent directory.
Enjoy and have fun!
Last updated