mirror of
https://github.com/LCTT/LFS-BOOK-7.7-systemd.git
synced 2026-01-14 00:49:09 +00:00
353 lines
18 KiB
HTML
353 lines
18 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
<title> 8.3. Linux-3.19 </title>
|
||
<link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css">
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||
<link rel="stylesheet" href="../stylesheets/lfs-print.css"
|
||
type="text/css" media="print">
|
||
</head>
|
||
<body class="lfs" id="lfs-7.7-systemd">
|
||
<div class="navheader">
|
||
<h4> Linux From Scratch - Version 7.7-systemd </h4>
|
||
<h3> 第八章 让 LFS 系统可引导</h3>
|
||
<ul>
|
||
<li class="prev"> <a accesskey="p" href="fstab.html"
|
||
title="Creating the /etc/fstab File">上一页</a>
|
||
<p> 创建 /etc/fstab 文件 </p>
|
||
</li>
|
||
<li class="next"> <a accesskey="n" href="grub.html"
|
||
title="Using GRUB to Set Up the Boot Process">下一页</a>
|
||
<p> 使用 GRUB 设置启动过程 </p>
|
||
</li>
|
||
<li class="up"> <a accesskey="u" href="chapter08.html"
|
||
title="Chapter 8. Making the LFS System Bootable">返
|
||
回</a> </li>
|
||
<li class="home"> <a accesskey="h" href="../index.html"
|
||
title="Linux From Scratch - Version 7.7-systemd">主页</a> </li>
|
||
</ul>
|
||
</div>
|
||
<div class="wrap" xml:lang="en" lang="en">
|
||
<h1 class="sect1"> <a id="ch-bootable-kernel"
|
||
name="ch-bootable-kernel"></a>8.3. Linux-3.19 </h1>
|
||
<div class="package" xml:lang="en" lang="en">
|
||
<p> Linux 软件包包含 Linux 内核。 </p>
|
||
<div class="segmentedlist">
|
||
<div class="seglistitem">
|
||
<div class="seg"> <strong class="segtitle">大概编译时间:</strong><span
|
||
class="segbody">3.0 - 49.0 SBU (typically about 6 SBU)</span>
|
||
</div>
|
||
<div class="seg"> <strong class="segtitle">所需磁盘空间:</strong><span
|
||
class="segbody">700 - 6800 MB (typically about 800-900
|
||
MB)</span> </div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="installation" xml:lang="en" lang="en">
|
||
<h2 class="sect2"> 8.3.1. 安装内核</h2>
|
||
<p> 编译内核包括以下步骤——配置、编译和安装。阅读内核源码树中的 <code class="filename">README</code>
|
||
可以获得替代本手册配置的方法。</p>
|
||
<p> 通过以下命令来编译:</p>
|
||
<pre class="userinput"><kbd class="command">make mrproper</kbd>
|
||
</pre>
|
||
<p> 这将保证内核树的绝对干净。内核小组建议在每次编译之前都执行此命令,无用的代码将会在解压后删除。</p>
|
||
<p> 通过菜单界面配置内核。配置内核的一般信息请查看:<a class="ulink"
|
||
href="http://www.linuxfromscratch.org/hints/downloads/files/kernel-configuration.txt">http://www.linuxfromscratch.org/hints/downloads/files/kernel-configuration.txt</a>。BLFS
|
||
包含有一些内核的特殊配置,可以查看:<a class="ulink"
|
||
href="http://www.linuxfromscratch.org/blfs/view/systemd/longindex.html#kernel-config-index">http://www.linuxfromscratch.org/blfs/view/systemd/longindex.html#kernel-config-index</a>.
|
||
内核配置和编译的附加信息可查看:<a class="ulink"
|
||
href="http://www.kroah.com/lkn/">http://www.kroah.com/lkn/</a>
|
||
</p>
|
||
<div class="admon note"> <img alt="[Note]"
|
||
src="../images/note.png">
|
||
<h3> 注意 </h3>
|
||
<p> A good starting place for setting up the kernel
|
||
configuration is to run <span class="command"><strong>make
|
||
defconfig</strong></span>. This will set the base
|
||
configuration to a good state that takes your current system
|
||
architecture into account. </p>
|
||
<p> Be sure to enable or disable following features or the
|
||
system might not work correctly or boot at all: </p>
|
||
<pre class="screen">General setup --->
|
||
[*] open by fhandle syscalls [CONFIG_FHANDLE]
|
||
[ ] Auditing support [CONFIG_AUDIT]
|
||
[*] Control Group support [CONFIG_CGROUPS]
|
||
Processor type and features --->
|
||
[*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP]
|
||
Networking support --->
|
||
Networking options --->
|
||
<*> The IPv6 protocol [CONFIG_IPV6]
|
||
Device Drivers --->
|
||
Generic Driver Options --->
|
||
[ ] Support for uevent helper [CONFIG_UEVENT_HELPER]
|
||
[*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS]
|
||
[ ] Fallback user-helper invocation for firmware loading [CONFIG_FW_LOADER_USER_HELPER]
|
||
Firmware Drivers --->
|
||
[*] Export DMI identification via sysfs to userspace [CONFIG_DMIID]
|
||
File systems --->
|
||
[*] Inotify support for userspace [CONFIG_INOTIFY_USER]
|
||
<*> Kernel automounter version 4 support (also supports v3) [CONFIG_AUTOFS4_FS]
|
||
Pseudo filesystems --->
|
||
[*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL]
|
||
[*] Tmpfs extended attributes [CONFIG_TMPFS_XATTR]
|
||
</pre>
|
||
</div>
|
||
<div class="admon note"> <img alt="[Note]"
|
||
src="../images/note.png">
|
||
<h3> Note </h3>
|
||
<p> While "The IPv6 Protocol" is not strictly required, it is
|
||
highly recommended by the systemd developers. </p>
|
||
</div>
|
||
<div class="variablelist">
|
||
<p class="title"> <strong>The rationale for the above
|
||
configuration items:</strong> </p>
|
||
<dl class="variablelist">
|
||
<dt> <span class="term"><em class="parameter"><code>Support
|
||
for uevent helper</code></em></span> </dt>
|
||
<dd>
|
||
<p> Having this opion set may interfere with device
|
||
management when using Udev/Eudev. </p>
|
||
</dd>
|
||
<dt> <span class="term"><em class="parameter"><code>Maintain
|
||
|
||
a devtmpfs</code></em></span> </dt>
|
||
<dd>
|
||
<p> This will create automated device nodes which are
|
||
populated by the kernel, even without Udev running. Udev
|
||
then runs on top of this, managing permissions and
|
||
adding symlinks. This configuration item is required for
|
||
all users of Udev/Eudev. </p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<pre class="userinput"><kbd class="command">make LANG=<em class="replaceable"><code><host_LANG_value></code></em> LC_ALL= menuconfig</kbd>
|
||
</pre>
|
||
<div class="variablelist">
|
||
<p class="title"> <strong>The meaning of the make parameters:</strong>
|
||
</p>
|
||
<dl class="variablelist">
|
||
<dt> <span class="term"><em class="parameter"><code>LANG=<host_LANG_value>
|
||
|
||
|
||
LC_ALL=</code></em></span> </dt>
|
||
<dd>
|
||
<p> This establishes the locale setting to the one used on
|
||
the host. This is needed for a proper menuconfig ncurses
|
||
interface line drawing on UTF-8 linux text console. </p>
|
||
<p> Be sure to replace <em class="replaceable"><code><host_LANG_value></code></em>
|
||
by the value of the <code class="envar">$LANG</code>
|
||
variable from your host. If not set, you could use
|
||
instead the host's value of <code class="envar">$LC_ALL</code>
|
||
or <code class="envar">$LC_CTYPE</code>. </p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<p> Alternatively, <span class="command"><strong>make oldconfig</strong></span>
|
||
may be more appropriate in some situations. See the <code
|
||
class="filename">README</code> file for more information. </p>
|
||
<p> If desired, skip kernel configuration by copying the kernel
|
||
config file, <code class="filename">.config</code>, from the
|
||
host system (assuming it is available) to the unpacked <code
|
||
class="filename">linux-3.19</code> directory. However, we do
|
||
not recommend this option. It is often better to explore all
|
||
the configuration menus and create the kernel configuration
|
||
from scratch. </p>
|
||
<p> Compile the kernel image and modules: </p>
|
||
<pre class="userinput"><kbd class="command">make</kbd>
|
||
</pre>
|
||
<p> If using kernel modules, module configuration in <code
|
||
class="filename">/etc/modprobe.d</code> may be required.
|
||
Information pertaining to modules and kernel configuration is
|
||
located in <a class="xref" href="../chapter07/udev.html"
|
||
title="7.3. Device and Module Handling on an LFS
|
||
System">Section 7.3, “Device and Module Handling on an
|
||
LFS System”</a> and in the kernel documentation in the <code
|
||
class="filename">linux-3.19/Documentation</code> directory.
|
||
Also, <code class="filename">modprobe.d(5)</code> may be of
|
||
interest. </p>
|
||
<p> Install the modules, if the kernel configuration uses them:
|
||
</p>
|
||
<pre class="userinput"><kbd class="command">make modules_install</kbd>
|
||
</pre>
|
||
<p> After kernel compilation is complete, additional steps are
|
||
required to complete the installation. Some files need to be
|
||
copied to the <code class="filename">/boot</code> directory.
|
||
</p>
|
||
<p> The path to the kernel image may vary depending on the
|
||
platform being used. The filename below can be changed to suit
|
||
your taste, but the stem of the filename should be <span
|
||
class="emphasis"><em>vmlinuz</em></span> to be compatible
|
||
with the automatic setup of the boot process described in the
|
||
next section. The following command assumes an x86
|
||
architecture: </p>
|
||
<pre class="userinput"><kbd class="command">cp -v arch/x86/boot/bzImage /boot/vmlinuz-3.19-lfs-7.7-systemd</kbd>
|
||
</pre>
|
||
<p> <code class="filename">System.map</code> is a symbol file
|
||
for the kernel. It maps the function entry points of every
|
||
function in the kernel API, as well as the addresses of the
|
||
kernel data structures for the running kernel. It is used as a
|
||
resource when investigating kernel problems. Issue the
|
||
following command to install the map file: </p>
|
||
<pre class="userinput"><kbd class="command">cp -v System.map /boot/System.map-3.19</kbd>
|
||
</pre>
|
||
<p> The kernel configuration file <code class="filename">.config</code>
|
||
produced by the <span class="command"><strong>make menuconfig</strong></span>
|
||
step above contains all the configuration selections for the
|
||
kernel that was just compiled. It is a good idea to keep this
|
||
file for future reference: </p>
|
||
<pre class="userinput"><kbd class="command">cp -v .config /boot/config-3.19</kbd>
|
||
</pre>
|
||
<p> Install the documentation for the Linux kernel: </p>
|
||
<pre class="userinput"><kbd class="command">install -d /usr/share/doc/linux-3.19
|
||
cp -r Documentation/* /usr/share/doc/linux-3.19</kbd>
|
||
</pre>
|
||
<p> It is important to note that the files in the kernel source
|
||
directory are not owned by <span class="emphasis"><em>root</em></span>.
|
||
Whenever a package is unpacked as user <span class="emphasis"><em>root</em></span>
|
||
(like we did inside chroot), the files have the user and group
|
||
IDs of whatever they were on the packager's computer. This is
|
||
usually not a problem for any other package to be installed
|
||
because the source tree is removed after the installation.
|
||
However, the Linux source tree is often retained for a long
|
||
time. Because of this, there is a chance that whatever user ID
|
||
the packager used will be assigned to somebody on the machine.
|
||
That person would then have write access to the kernel source.
|
||
</p>
|
||
<p> If the kernel source tree is going to be retained, run <span
|
||
class="command"><strong>chown -R 0:0</strong></span> on the
|
||
<code class="filename">linux-3.19</code> directory to ensure
|
||
all files are owned by user <span class="emphasis"><em>root</em></span>.
|
||
</p>
|
||
<div class="admon warning"> <img alt="[Warning]"
|
||
src="../images/warning.png">
|
||
<h3> 警告 </h3>
|
||
<p> Some kernel documentation recommends creating a symlink
|
||
from <code class="filename">/usr/src/linux</code> pointing
|
||
to the kernel source directory. This is specific to kernels
|
||
prior to the 2.6 series and <span class="emphasis"><em>must
|
||
not</em></span> be created on an LFS system as it can
|
||
cause problems for packages you may wish to build once your
|
||
base LFS system is complete. </p>
|
||
</div>
|
||
<div class="admon warning"> <img alt="[Warning]"
|
||
src="../images/warning.png">
|
||
<h3> 警告 </h3>
|
||
<p> The headers in the system's <code class="filename">include</code>
|
||
directory (<code class="filename">/usr/include</code>)
|
||
should <span class="emphasis"><em>always</em></span> be the
|
||
ones against which Glibc was compiled, that is, the
|
||
sanitised headers installed in <a class="xref"
|
||
href="../chapter06/linux-headers.html"
|
||
title="6.7. Linux-3.19 API Headers">Section 6.7,
|
||
“Linux-3.19 API Headers”</a>. Therefore, they should <span
|
||
class="emphasis"><em>never</em></span> be replaced by
|
||
either the raw kernel headers or any other kernel sanitized
|
||
headers. </p>
|
||
</div>
|
||
</div>
|
||
<div class="configuration" xml:lang="en" lang="en">
|
||
<h2 class="sect2"> <a id="conf-modprobe" name="conf-modprobe"></a>8.3.2.
|
||
配置 Linux 模块加载顺序 </h2>
|
||
<p> 虽然大多数情况下,Linux 模块自动加载就好,但是有时候需要特别指定加载顺序。<span
|
||
class="command"><strong>modprobe</strong></span> 或 <span
|
||
class="command"><strong>insmod</strong></span> 在加载模块时会读取 <code
|
||
class="filename">/etc/modprobe.d/usb.conf</code> 。如果将 USB
|
||
设备(ehci_hcd、ohci_hcd 和 uhci_hcd)
|
||
<meta http-equiv="content-type" content="text/html;
|
||
charset=UTF-8">
|
||
编译为模块,则需要此文件,这样它们就会以正确的顺序加载。ehci_hcd 需要在 ohci_hcd 和
|
||
uhci_hcd 之前加载,否则在系统启动过程中将会输出警告。</p>
|
||
<p> 运行以下命令建立<code> </code><code class="filename">/etc/modprobe.d/usb.conf</code>
|
||
文件: </p>
|
||
<pre class="userinput"><kbd class="command">install -v -m755 -d /etc/modprobe.d
|
||
cat > /etc/modprobe.d/usb.conf << "EOF"
|
||
<code class="literal"># Begin /etc/modprobe.d/usb.conf
|
||
|
||
install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
|
||
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
|
||
|
||
# End /etc/modprobe.d/usb.conf</code>
|
||
EOF</kbd>
|
||
</pre>
|
||
</div>
|
||
<div class="content" xml:lang="en" lang="en">
|
||
<h2 class="sect2"> <a id="contents-kernel"
|
||
name="contents-kernel"></a>8.3.3. Linux 的内容<br>
|
||
</h2>
|
||
<div class="segmentedlist">
|
||
<div class="seglistitem">
|
||
<div class="seg"> <strong class="segtitle">安装的文件:</strong><span
|
||
class="segbody">config-3.19,
|
||
vmlinuz-3.19-lfs-7.7-systemd, and System.map-3.19</span>
|
||
</div>
|
||
<div class="seg"> <strong class="segtitle">安装的目录:</strong><span
|
||
class="segbody">/lib/modules, /usr/share/doc/linux-3.19</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="variablelist">
|
||
<h3> 简要说明</h3>
|
||
<table class="variablelist" border="0">
|
||
<colgroup> <col valign="top" align="left"> <col> </colgroup>
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<p> <a id="config" name="config"></a><span
|
||
class="term"><code class="filename">config-3.19</code></span>
|
||
</p>
|
||
</td>
|
||
<td>
|
||
<p> 包含内核的所有配置选项 </p>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<p> <a id="lfskernel" name="lfskernel"></a><span
|
||
class="term"><code class="filename">vmlinuz-3.19-lfs-7.7-systemd</code></span>
|
||
</p>
|
||
</td>
|
||
<td>
|
||
<p> Linux
|
||
系统的引擎。当电脑启动,内核作为整个系统的第一部分载入。它首先检测和初始化所有的电脑硬件,然后 then
|
||
makes these components available as a tree of files
|
||
to the software and turns a single CPU into a
|
||
multitasking machine capable of running scores of
|
||
programs seemingly at the same time </p>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<p> <a id="System.map" name="System.map"></a><span
|
||
class="term"><code class="filename">System.map-3.19</code></span>
|
||
</p>
|
||
</td>
|
||
<td>
|
||
<p> 地址和符号列表;包含有入口点的映射以及所有函数和内核数据结构的地址</p>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="navfooter">
|
||
<ul>
|
||
<li class="prev"> <a accesskey="p" href="fstab.html"
|
||
title="Creating the /etc/fstab File">上一页</a>
|
||
<p> 创建 /etc/fstab 文件 </p>
|
||
</li>
|
||
<li class="next"> <a accesskey="n" href="grub.html"
|
||
title="Using GRUB to Set Up the Boot Process">下一页</a>
|
||
<p> 使用 GRUB 设置启动过程 </p>
|
||
</li>
|
||
<li class="up"> <a accesskey="u" href="chapter08.html"
|
||
title="Chapter 8. Making the LFS System Bootable">返
|
||
回</a> </li>
|
||
<li class="home"> <a accesskey="h" href="../index.html"
|
||
title="Linux From Scratch - Version 7.7-systemd">主页</a> </li>
|
||
</ul>
|
||
</div>
|
||
</body>
|
||
</html>
|