在 18.04.1-Ubuntu 下的 VirtualBox 中构建最新的 Linux 内核时出错

问题描述 投票:0回答:2

我正在尝试使用 Oracel VM 和 18.04.1-Ubuntu 映像构建最新的 Linux 内核 (GitHub)。

我安装了所需的软件包,甚至可能更多。这是我安装的部分软件包:

sudo apt-get update
sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc bison flex libelf-def kernel-package

完整列表可以在这里找到。

从 GitHub 克隆存储库后,我在

linux
文件夹中运行了以下命令。

$ cp /boot/config-$(uname -r) .config

$ make menuconfig
scripts/kconfig/mconf  Kconfig
.config:1118:warning: symbol value 'm' invalid for NF_CT_PROTO_GRE
.config:1923:warning: symbol value 'm' invalid for NET_DEVLINK
.config:7865:warning: symbol value 'm' invalid for ASHMEM
.config:8724:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
.config:8725:warning: symbol value 'm' invalid for ANDROID_BINDERFS


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

我保存并退出

menuconfig
。最后 make 导致以下错误。

$ make -j2
Makefile:608: include/config/auto.conf: No such file or directory
Makefile:660: include/config/auto.conf.cmd: No such file or directory
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --syncconfig Kconfig

*** Error during sync of the configuration.

scripts/kconfig/Makefile:73: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 1
Makefile:562: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 2
Makefile:678: recipe for target 'include/config/auto.conf.cmd' failed
make: *** [include/config/auto.conf.cmd] Error 2
make: *** Deleting file 'include/config/auto.conf.cmd'

看起来 make 需要一些额外的配置文件

include/config/auto.conf
。有没有人给我一个线索。

谢谢!

linux-kernel virtualbox building
2个回答
4
投票

尝试以非root身份编译内核5.6.3时,我遇到了这个问题。 运行 Oandiy 评论中的建议

git clean -xdf

显示我的源代码树中的文件属于 root 用户且无法删除。回顾我的历史,我发现,

sudo make localmodconfig  # DO NOT DO THIS

以 root 身份在

include/config/*
include/generated/autoconf.h
中安装了文件。

要查看是否有同样的问题,请运行

sudo find . -uid 0

或者只看

git clean -xdf
的错误消息(不应该有)。

删除 root 拥有的所有文件和目录后,我从这个死锁中恢复过来:

unset ARCH
cp .config ../config.backup  # If you still have this.
git clean -xdf               # No errors (this also deletes .config)
cp ../config.backup .config  # Or generate a new one *).
make olddefconfig            # Printed at the end: 'No change to .config'

请注意,我需要从我的环境中清除 ARCH。

此后我像往常一样继续,

VERSION=5.6.3                # I have checked out tag v5.6.3 **)
FLAVOUR=lowlatlocxhci        # Or whatever you want to call your kernel.
make -j8 deb-pkg LOCALVERSION=-$FLAVOUR
sudo dpkg -i ../linux-headers-$VERSION-${FLAVOUR}_$VERSION-$FLAVOUR-1_amd64.deb ../linux-image-$VERSION-${FLAVOUR}_$VERSION-${FLAVOUR}-1_amd64.deb

最后一个命令目前无法编译 virtualbox 内核模块,但我不关心这些,并且这些错误可以忽略(只要你不使用 virtual box)。

*)使用的 .config 是通过引导到包含所有内容的内核(即 dist.kernel)来准备的,将其配置从 /boot 复制到源代码树并在确保我需要的所有内核模块位于其中后运行

make localmodconfig
已加载(通过运行导致加载此类模块的应用程序)。最后运行
make menuconfig
来关闭该内核中的
CONFIG_DEBUG_INFO
并将通常内置于内核中的一些内容也转换为模块(出于某种原因我需要这些)。

**)我的 git 树已经准备好了:

VERSION=5.6.3
FLAVOUR=lowlatlocxhci
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-$VERSION-$FLAVOUR-$VERSION-$FLAVOUR
cd linux-$VERSION-$FLAVOUR-$VERSION-$FLAVOUR
git checkout -b test_$FLAVOUR v$VERSION
# Make manual changes here, and commit as usual.

0
投票

像这样的问题通常是由于文件权限造成的,我以非root身份编译内核, 在编译之前,从linux源目录(通常是/usr/src/linux)

"chown -R myuser:myuser *"
© www.soinside.com 2019 - 2024. All rights reserved.