kubectl-trace icon indicating copy to clipboard operation
kubectl-trace copied to clipboard

Kernel headers not found in `/usr/src`

Open fandahao17 opened this issue 3 years ago • 1 comments

On some distributions (e.g., my CentOS 7) /lib/modules/$(uname -r)/build is a symlink to the real kernel header directory in /usr/src/kernels/$(uname -r).

root@bpftrace-pod:/# ls -al /lib/modules/5.4.146
total 4636
drwxr-xr-x   4 root root    4096 Oct 28 13:00 .
drwxr-xr-x. 10 root root     255 Oct 28 11:20 ..
lrwxrwxrwx   1 root root      24 Oct 28 13:00 build -> /usr/src/kernels/5.4.146
... (Omiited to save space)

Thus, #77 mounted /usr/src in the pod template to include the kernel headers. #103 later mounted the whole /usr/ to avoid potentially creating /usr/src on the host. /usr is mounted as /usr-host in the guest pod and a symlink is created in the pod from /usr/src to /usr-host/src, so bpftrace can still find the kernel headers through the symlink.

However, in #104 this symlink seems to be removed, leaving /usr/src/ empty.

root@bpftrace-pod:/# ls -al /usr/src
total 0
drwxr-xr-x 2 root root  6 Apr 15  2020 .
drwxr-xr-x 1 root root 25 Jun  9 07:27 ..

Consequently, bpftrace is not able to find the kernel headers, which causes /bpftrace/include/clang_workarounds.h:14:10: fatal error: 'linux/types.h' file not found. This repo has multiple issues regarding this error.

I guess re-linking /usr/src to /usr-host could fix this problem.

fandahao17 avatar Oct 28 '21 14:10 fandahao17

I am facing the same problem. image

rajeeshckr avatar Dec 21 '22 04:12 rajeeshckr