
在學習如何建構和安裝自訂核心(用於核心駭客)時,我遇到了一個矛盾的說法。
在這個堆疊交換答案,作者指出:
在下面的說明中,原始碼樹內的路徑採用 [src]/whatever 的形式,其中 [src] 是安裝原始程式碼的目錄,例如 /usr/src/linux-3.13.3。您可能想要執行此操作 su root,因為來源樹應該在寫入權限方面保持安全(它應該由 root 擁有)。
他在參考書中提到:Linux 核心簡述,格雷格·克羅哈特曼 說:
在完成本書中的步驟時,這個警告是需要記住的最重要的事情。本書中的所有內容——下載核心原始碼、解壓縮、配置核心和建構它——都應該以機器上的普通用戶身份完成。僅應以超級使用者 (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 下建立。