自定义命名内核,以便通过“uname -sr”显示

自定义命名内核,以便通过“uname -sr”显示

我是 Ubuntu 的新手,我被赋予一项任务,下载内核更新并自定义名称,以便在更新后当有人输入时,uname -sr它应该显示自定义名称而不是内核版本。

也就是说,如果老师执行命令uname –r,它必须显示我的学号作为内核版本。

我已经更新了内核,现在想更改名称,但不知道如何操作。我在 Google 和 YouTube 上搜索过,但没有找到任何相关信息。

答案1

如果你在这里询问,那么我假设你使用的是 Ubuntu。这里是指令,您如何基于 xanmod 重命名并编译自己的内核。我使用此指令是因为我过去曾使用过它,并且我在 19.10 Lenovo G55 上成功运行。

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install build-essential bison flex gcc-8 g++-8
# It is also good to verify which version of GCC runs
# by default.
gcc -v

# If an older version of GCC pops up, you should update
# the default choice. update-alternatives is the preferred
# way to handle stuff like this, which you can achieve with
# something like the following:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo update-alternatives --config gcc

git clone https://github.com/xanmod/linux.git xanmod --branch 4.17
# You could try other branch release

cd xanmod
make clean

make menuconfig
# It is if you want to modify something. When it will be opened, just Save and Exit.

make localmodconfig
# Any module deemed unnecessary will automatically be removed from your existing build config.

make -j2 deb-pkg LOCALVERSION=-custom
# custom here is what your teacher asks for

安装:

sudo dpkg -i ../linux-headers*.deb ../linux-image*.deb

重新启动进入新内核并尝试uname

相关内容