
カスタム カーネル (カーネル ハッキング用) の構築とインストール方法を学習しているときに、矛盾した記述に遭遇しました。
このStackExchangeの回答著者は次のように述べています。
以下の手順では、ソース ツリー内のパスは [src]/whatever という形式になります。ここで、[src] はソースをインストールしたディレクトリです (例: /usr/src/linux-3.13.3)。ソース ツリーは書き込み権限の点で安全なままである必要があるため (所有者は root である必要があります)、この操作は su root で実行することをお勧めします。
参考書の中で彼はこう言っています。Linuxカーネルの概要グレッグ・クロア・ハートマンはこう言う。
この警告は、この本の手順を実行する際に覚えておくべき最も重要なことです。この本のすべて、つまりカーネル ソース コードのダウンロード、解凍、カーネルの設定、およびビルドは、マシン上の通常のユーザーとして実行する必要があります。新しいカーネルをインストールするために必要な 2 つまたは 3 つのコマンドのみ、スーパーユーザー (root) として実行する必要があります。
そして
カーネル ソース コードは、/usr/src/linux/ ディレクトリに置かないでください。これは、システム ライブラリが構築されたカーネルの場所であり、新しいカスタム カーネルの場所ではないためです。/usr/src/ ディレクトリ ツリーの下ではカーネル開発を行わず、システムに悪影響が及ばないローカル ユーザー ディレクトリでのみカーネル開発を行うようにしてください。
どちらの情報源もかなり古いものですが、今日ではこれに対する正しいアプローチは何でしょうか?
答え1
/usr
「カスタム」に関するものはここには存在しません:
ここにいます:
/usr/src
Source files for different parts of the system, included with some packages for reference purposes. Don't work
here with your own projects, as files below /usr should be read-only except when installing software (optional).
/usr/src/linux
This was the traditional place for the kernel source. Some distributions put here the source for the default
kernel they ship. You should probably use another directory when building your own kernel.
man ファイル階層:
/usr/
Vendor-supplied operating system resources. Usually read-only, but this is not required. Possibly shared between
multiple hosts. This directory should not be modified by the administrator, except when installing or removing
vendor-supplied packages.
/usr/include
以前は頼りにしていた/usr/src/linux
:
/usr/include/linux
This contains information which may change from system release to system release and used to be a symbolic link
to /usr/src/linux/include/linux to get at operating-system-specific information.
したがって、カーネル ソースは/usr/src
参照のみ可能であり、変更することはできません。
ビルドを読み取り専用にするためのオプションがDocumentation/admin-guide/README.rst
表示されます。O=
/usr/src/linux-VERSION
cd /usr/src/linux-4.X
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
同様に、.config ファイルも /home の下に作成されます。