WSL2直接使用perf会报没有安装的错误:

WARNING: perf not found for kernel 4.4.0-18362

You may need to install the following packages for this specific kernel:

linux-tools-4.4.0-18362-Microsoft

linux-cloud-tools-4.4.0-18362-Microsoft

You may also want to install one of the following packages to keep up to date:

linux-tools-Microsoft

linux-cloud-tools-Microsoft

这时候这样安装,更新一下

#可以多来几次
sudo apt-get update
sudo apt-get upgrade

然后下载:

sudo apt install build-essential flex bison libssl-dev libelf-dev
git clone --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git

然后编译compile

cd WSL2-Linux-Kernel/tools/perf
make

这时候知识把perf安装到了指定这个目录下,只可以在这个目录启动。网上很多帖子就到此为止,其实还有关键一步,否则即使在其他目录下使用perf,还是会报开头的没有安装的错误:

$sudo cp perf /usr/bin

这样才算安装完成。
这一步不做,虽然which perf也能在/usr/bin下找到perf,但是用不了,只有这一步做了才可以!!!

大部分的帖子

一个风格独特的帖子

我的环境:
win10 + WSL2, 肯定是Ubuntu.

WSL2的shell下检查下。

 cat /proc/version
 显示:
Linux version 5.4.72-microsoft-standard-WSL2
Logo

更多推荐