I am learning eBPF and try to install bcc in WSL environment. I follow the official document to compile the kernel module manually, then install BCC from source, and after
sudo mount -t debugfs debugfs /sys/kernel/debug
I attempt to run some bcc examples and tools and they all work well. But after some time or after restart of the WSL, these bcc programs can not work any more with errors like
chdir(/tmp/kheaders-5.15.146.1-microsoft-standard-WSL2): No such file or directoryTraceback (most recent call last): File "./opensnoop", line 289, in <module> b = BPF(text='') File "/usr/lib/python3/dist-packages/bcc-0.29.1+008ea09e-py3.8.egg/bcc/__init__.py", line 479, in __init__Exception: Failed to compile BPF module <text>
and I find the installed contents in /lib/modules/$KERNEL_VERSION-microsoft-standard-WSL2
are reset, with totally different file modification time. I need to manually install the kernel modules again to make the bcc programs work well again.
Comparison of the contents of /lib/modules/$KERNEL_VERSION-microsoft-standard-WSL2
:
fresh:
lrwxrwxrwx 1 root root 38 Apr 2 20:05 build -> /MY_BUILD_PATH/WSL2-Linux-Kerneldrwxr-xr-x 4 root root 80 Apr 2 20:05 kernel-rw-r--r-- 1 root root 58136 Apr 2 20:05 modules.alias-rw-r--r-- 1 root root 59354 Apr 2 20:05 modules.alias.bin-rw-r--r-- 1 root root 15144 Apr 2 20:05 modules.builtin-rw-r--r-- 1 root root 44804 Apr 2 20:05 modules.builtin.alias.bin-rw-r--r-- 1 root root 17273 Apr 2 20:05 modules.builtin.bin-rw-r--r-- 1 root root 111270 Apr 2 20:05 modules.builtin.modinfo-rw-r--r-- 1 root root 619 Apr 2 20:05 modules.dep-rw-r--r-- 1 root root 1150 Apr 2 20:05 modules.dep.bin-rw-r--r-- 1 root root 0 Apr 2 20:05 modules.devname-rw-r--r-- 1 root root 434 Apr 2 20:05 modules.order-rw-r--r-- 1 root root 55 Apr 2 20:05 modules.softdep-rw-r--r-- 1 root root 1286 Apr 2 20:05 modules.symbols-rw-r--r-- 1 root root 1294 Apr 2 20:05 modules.symbols.binlrwxrwxrwx 1 root root 38 Apr 2 20:05 source -> /MY_BUILD_PATH/WSL2-Linux-Kernel
stale:
dr-xr-xr-x 1 root root 4096 Mar 23 11:21 kernel-r-xr-xr-x 1 root root 58136 Jan 11 04:27 modules.alias-r-xr-xr-x 1 root root 59354 Jan 11 04:27 modules.alias.bin-r-xr-xr-x 1 root root 15144 Jan 11 04:27 modules.builtin-r-xr-xr-x 1 root root 44804 Jan 11 04:27 modules.builtin.alias.bin-r-xr-xr-x 1 root root 17273 Jan 11 04:27 modules.builtin.bin-r-xr-xr-x 1 root root 111270 Jan 11 04:27 modules.builtin.modinfo-r-xr-xr-x 1 root root 619 Jan 11 04:27 modules.dep-r-xr-xr-x 1 root root 1150 Jan 11 04:27 modules.dep.bin-r-xr-xr-x 1 root root 0 Jan 11 04:27 modules.devname-r-xr-xr-x 1 root root 434 Jan 11 04:27 modules.order-r-xr-xr-x 1 root root 55 Jan 11 04:27 modules.softdep-r-xr-xr-x 1 root root 1286 Jan 11 04:27 modules.symbols-r-xr-xr-x 1 root root 1294 Jan 11 04:27 modules.symbols.bin
2 directory links build
and source
disappear.
My environment:
Ubuntu 20.04.6 LTS,kernel 5.15.146.1-microsoft-standard-WSL2,in WSL2,Windows 10 enterprise, 22H2, 19045.4170
I do not understand why. Any guidance?