mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
[ѷ] 05 The Linux Kernel--Configuring the Kernel Part 1
This commit is contained in:
parent
7f3545f648
commit
889ad851da
@ -1,74 +0,0 @@
|
|||||||
Translating------------------geekpi
|
|
||||||
|
|
||||||
05 The Linux Kernel: Configuring the Kernel Part 1
|
|
||||||
================================================================================
|
|
||||||
![](http://www.linux.org/attachments/slide-jpg.299/)
|
|
||||||
|
|
||||||
Now that we understand the Linux kernel, we can move on to the main event - configuring and compiling the code. Configuring code for the kernel does take a lot of time. The configuration tool asks many questions and allows developers to configure every aspect of the kernel. If unsure about any question or feature, it is best to pick the default value provided by the configuration tool. This tutorial series will walk readers through the whole process of configuring the kernel.
|
|
||||||
|
|
||||||
To configure the code, open a terminal in the main source code folder. Once a terminal is up, there are a few ways to configure the code based on the preferred configuration interface.
|
|
||||||
|
|
||||||
make config - Plain text interface (most commonly used choice)
|
|
||||||
make menuconfig - Text-based with colored menus and radiolists. This options allows developers to save their progress. - ncurses (ncurses-devel) must be installed
|
|
||||||
make nconfig - Text-based colored menus - curses (libcdk5-dev) must be installed
|
|
||||||
make xconfig - QT/X-windows interface – QT is required
|
|
||||||
make gconfig - Gtk/X-windows interface – GTK is required
|
|
||||||
make oldconfig - Plain text interface that defaults questions based on the local config file
|
|
||||||
make silentoldconfig - This is the same as oldconfig except the questions answered by the config file will not be shown
|
|
||||||
make olddefconfig - This is like silentoldconfig except some questions are answered by their defaults
|
|
||||||
make defconfig - This option creates a config file that uses default settings based on the current system's architecture.
|
|
||||||
make ${PLATFORM}_defconfig - Creates a config file using values from arch/$ARCH/configs/${PLATFORM}_defconfig.
|
|
||||||
make allyesconfig - This option creates a config file that will answer yes to as many questions as possible.
|
|
||||||
make allmodconfig - This option creates a config file that will make as many parts of the kernel a module as possible
|
|
||||||
|
|
||||||
NOTE: Code in the Linux kernel can be put in the kernel itself or made as a module. For instance, users can add Bluetooth drivers as a module (separate from the kernel), add to the kernel itself, or not add at all. When code is added to the kernel itself, the kernel requires more RAM space and boot-up time may take longer. However, the kernel will perform better. If code is added as modules, the code will remain on the hard-drive until the code is needed. Then, the module is loaded to RAM. This will reduce the kernel's RAM usage and decrease boot time. However, the kernel's performance may suffer because the kernel and the modules will be spread throughout the RAM. The other choice is to not add some code. For illustration, a kernel developer may know that a system will never use Bluetooth devices. As a result, the drivers are not added to the kernel. This improves the kernel's performance. However, if users later need Bluetooth devices, they will need to install Bluetooth modules or update the whole kernel.
|
|
||||||
|
|
||||||
make allnoconfig - This option creates a config file that will only add essential code to the kernel; this answers no to as many questions as possible. This can sometimes make a kernel that does not work on the hardware it was compiled on.
|
|
||||||
make randconfig - This option makes random choices for the kernel
|
|
||||||
make localmodconfig - This option creates a config file based on the current list of loaded modules and system configuration.
|
|
||||||
make localyesconfig - This will set all module options to yes - most (or all) of the kernel will not be in modules
|
|
||||||
|
|
||||||
TIP: It is best to use “make menuconfig” because users can save their progress. “make config” does not offer this luxury. Because the configuration process takes a lot of time,
|
|
||||||
|
|
||||||
### Configuration: ###
|
|
||||||
|
|
||||||
Most developers choose "make menuconfig" or one of the other graphical menus. After typing the desired command, the first question asks whether the kernel to be built is going to be a 64-bit kernel or not. The choices are "Y", "n", and "?". The question mark explains the question, "n" answers no to the question, and "Y" answers yes to the question. For this tutorial, I will choose yes. To do this I type "Y" (this is case-insensitive) and hit enter.
|
|
||||||
|
|
||||||
|
|
||||||
NOTE: If the kernel is compiled on a 32-bit system, then the configuration tool would ask if the kernel should be 32-bit. The first question is different on other processors.
|
|
||||||
|
|
||||||
The next line shows "Cross-compiler tool prefix (CROSS_COMPILE) []". If you are not cross-compiling, hit enter. If you are cross-compiling, type something like "arm-unknown-linux-gnu-" for ARM systems or "x86_64-pc-linux-gnu-" for 64-bit PC systems. There are many other possible commands for other processor types, but the list can be quite large. Once a developer knows what processor they want to support, it is easy to research the command needed for that processor.
|
|
||||||
|
|
||||||
NOTE: Cross-compiling is compiling code to be used on other processors. For illustration, an Intel system that is cross-compiling code is making applications for processors other than Intel. So, this system may be compiling code for ARM or AMD processors.
|
|
||||||
|
|
||||||
NOTE: Each choice will change which questions come up and when they are displayed. I will include my choices so readers can follow the configuration process on their own system.
|
|
||||||
|
|
||||||
Next, users will see "Local version - append to kernel release (LOCALVERSION) []". This is where developers can give a special version number or name to their customized kernel. I will type "LinuxDotOrg". The kernel version is now “3.9.4-LinuxDotOrg”. Next, the configuration tool asks "Automatically append version information to the version string (LOCALVERSION_AUTO) [N/y/?]". If a git tree is found, the revision number will be appended. This example is not using git, so I will answer no. Other wise the git revision number will be appended to the version. Remember vmlinuz and similar files? Well, the next question asks which compression format should be used. The developer can choose one through five. The choices are
|
|
||||||
|
|
||||||
1. Gzip (KERNEL_GZIP)
|
|
||||||
2. Bzip2 (KERNEL_BZIP2)
|
|
||||||
3. LZMA (KERNEL_LZMA)
|
|
||||||
4. XZ (KERNEL_XZ)
|
|
||||||
5. LZO (KERNEL_LZO)
|
|
||||||
|
|
||||||
Gzip is the default, so I will press “1” and hit enter. Each compression format has greater or less compression ratios compared to the other formats. A better compression ratio means a smaller file, but more time is needed to uncompress the file while the opposite applies to lower compression ratios.
|
|
||||||
|
|
||||||
Now, this line is displayed - “Default hostname (DEFAULT_HOSTNAME) [(none)]”. The default hostname can be configured. Usually, developers leave this blank (I left it blank) so that Linux users can set up their own hostname.
|
|
||||||
|
|
||||||
Next, developers can enable or disable the use of swap space. Linux uses a separate partition called “swap space” to use as virtual memory. This is equivalent to Windows' paging file. Typically, developers answer yes for the line “Support for paging of anonymous memory (swap) (SWAP) [Y/n/?]”.
|
|
||||||
|
|
||||||
The next line (System V IPC (SYSVIPC) [Y/n/?]) asks if the kernel should support IPC. Inter Process Communication allows processes to communicate and sync. It is best to enable IPC, otherwise, many applications will not work. Answering yes to this question will cause the configuration tool to ask “POSIX Message Queues (POSIX_MQUEUE) [Y/n/?]”. This question will only be seen if IPC is enabled. POSIX message queues is a messaging queue (a form of interprocess communication) where each message is given a priority. The default choice is yes. Hit enter to choose the default choice (indicated by the capitalized choice).
|
|
||||||
|
|
||||||
The next question (open by fhandle syscalls (FHANDLE) [Y/n/?]) is asking if programs will be permitted to use file handles instead of filenames when performing filesystem operations if needed. By default, the answer is yes.
|
|
||||||
|
|
||||||
Sometimes, when a developer has made certain choices, some questions will automatically be answered. For instance, the next question (Auditing support (AUDIT) [Y/?]) is answered yes without prompting because previous choices require this feature. Auditing-support logs the accesses and modifications of all files. The next question relates to auditing (Enable system-call auditing support (AUDITSYSCALL) [Y/n/?]). If enabled, all system calls are logged. If the developer wants performance, then as much auditing features as possible should be disabled and not added to the kernel. Some developers may enable auditing for security monitoring. I will select “no” for this question. The next audit question (Make audit loginuid immutable (AUDIT_LOGINUID_IMMUTABLE) [N/y/?]) is asking if processes can change their loginuid (LOGIN User ID). If enabled, processes in userspace will not be able to change their own loginuids. For better performance, we will disable this feature.
|
|
||||||
|
|
||||||
NOTE: When configuring via “make config”, the questions that are answered by the configuration tool are displayed, but the user does not have a way to change the answer. When configuring via “make menuconfig”, the user cannot change the option no matter what button is pressed. Developers should not want to change options like that anyway because a previous choice requires another question to be answered a certain way.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-1.4274/
|
|
||||||
|
|
||||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
@ -0,0 +1,71 @@
|
|||||||
|
05 Linux 内核: 配置内核(Part 1)
|
||||||
|
================================================================================
|
||||||
|
![](http://www.linux.org/attachments/slide-jpg.299/)
|
||||||
|
|
||||||
|
现在我们已经了解了内核,现在我们可以进入主要事项:配置并编译代码。配置内核代码并不会花费太长时间。配置工具会询问许多问题并且允许开发者配置内核的每个方面。如果你有不确定的问题或者特性,你最好使用配置工具提供的默认值。本系列教程会使读者逐步了解配置内核的整个过程。
|
||||||
|
|
||||||
|
配置代码前需要在源文件的文件夹内打开一个终端。当终端打开后,基于你喜好的配置界面,这里有几种不同的配置方法、
|
||||||
|
|
||||||
|
make config - 纯文本界面 (最常用的选择)。
|
||||||
|
make menuconfig - 基于文本彩色菜单和单选列表。这个选项可以加快开发者开发速度。必须安装ncurses(ncurses-devel)。
|
||||||
|
make nconfig - 基于文本的彩色菜单。必须安装curses (libcdk5-dev)。
|
||||||
|
make xconfig - QT/X-windows 界面。需要安装QT。
|
||||||
|
make gconfig - Gtk/X-windows 界面。需要安装GTK。
|
||||||
|
make oldconfig - 纯文本界面但问题基于本地配置文件。
|
||||||
|
make silentoldconfig - 和oldconfig相似但是不会显示配置文件中已有的问题。
|
||||||
|
make olddefconfig -和silentoldconfig相似但有些问题已经以它们的默认值选择。
|
||||||
|
make defconfig - 这个选项将会创建一份以当前系统架构为基础的默认设置文件。
|
||||||
|
make ${PLATFORM}_defconfig - 创建一份使用arch/$ARCH/configs/${PLATFORM}_defconfig中的值的配置文件。
|
||||||
|
make allyesconfig - 这个选项将会创建一根尽可能多的问题都为‘yes’的配置文件。
|
||||||
|
make allmodconfig - 这个选项将会创建一份将尽可能多的内核部分配置为模块的配置文件。
|
||||||
|
|
||||||
|
注意:内核代码可以放进内核中或者成为一个模块。例如,用户可以将蓝牙驱动作为一个模块加入(独立于内核),或者直接加入内核,或者完全不加蓝牙驱动。当代码加入内核本身时,内核将会请求更多的内存并且启动会花费更长的时间。然而,内核会执行的更好。如果代码作为模块加入,代码将会一直存在于硬盘上直到被需要时加载。接着模块加载到内存中。这可以减少内核的内存使用并减少启动的时间。然而,因为内核和模块在内存上相互独立所以会影响内核的性能。另一种选择是不添加一些代码。举例来说,内核开发人员可能知道系统永远都不会使用蓝牙设备。因此这个驱动不会加到内核中。这提升了内核的性能。然而,如果用户之后需要蓝牙设备,那么他么需要安装蓝牙模块或者升级内核。
|
||||||
|
|
||||||
|
make allnoconfig - 这个选项只会生成内核必要代码的配置文件。它对尽可能多的问题都回答no。这有时会导致内核无法工作在为该硬件编译的硬件上。
|
||||||
|
make randconfig - 这个选项会对内核选项随机选择。
|
||||||
|
make localmodconfig - 这个选项会根据当前已加载模块列表和系统配置来生成配置文件。
|
||||||
|
make localyesconfig - 将当前使用的模块都编译进内核(译者注:这里与原文 ‘This will set all module options to yes - most (or all) of the kernel will not be in modules’的意思不同,经过网络多处验证,译者认为这里可能是原作者笔误)。
|
||||||
|
|
||||||
|
贴士:最好使用“make menuconfig”因为用户可以加快进度。“make config”不会提供如此“奢侈品”。因为配置过程会耗费大量时间。
|
||||||
|
|
||||||
|
### 配置: ###
|
||||||
|
|
||||||
|
大多数开发者选择使用“make menucongfig”或者其他图形菜单。当要求的键入命令后,第一个问题是受否将内核编译成64位。选项有“Y”、“n”和“?”。问号用来解释这个问题,“n”代表这个问题回答否(no),"Y"代表这个问题回答是(yes).在这个教程里,我选择是。 这里我输入"Y"(这里是大小写敏感的)并输入回车。
|
||||||
|
|
||||||
|
注意:当内核在32位系统上编译时,编译工具会询问内核是否编译成32位。第一个问题在不同的处理器上不一样。
|
||||||
|
|
||||||
|
下一行显示的是"Cross-compiler tool prefix (CROSS_COMPILE) []".如果你没有在交叉编译就按下回车。如果你正在交叉编译,对ARM系统输入像"arm-unknown-linux-gnu-",对64位PC输入像"x86_64-pc-linux-gnu-"的字样。对其他处理器而言还有许多其他可能的命令,但是这个表太大了。一旦一名开发者知道他们想要支持的处理器,很容易就可研究出处理器需要的命令。
|
||||||
|
|
||||||
|
注意:交叉编译是在另外的处理器上编译代码。比如,一台Intel系统正编译着不在Intel处理器上运行的程序。因此,这个系统可能正在编译为在ARM或AMD处理期上运行的代码。
|
||||||
|
|
||||||
|
注意:每一项选择会改变接下来显示什么问题及何时显示。我会(在教程里)包含上我的选择让读者可以在他们自己的系统上跟上配置的进度。
|
||||||
|
|
||||||
|
接下来,用户会看到“Local version - append to kernel release (LOCALVERSION) []”。这使开发人员可以给定一个特殊版本号或他们自定义的内核。我将输入“LinuxDotOrg”。现在的内核版本会是“3.9.4-LinuxDotOrg”。接下来,配置工具会询问“Automatically append version information to the version string (LOCALVERSION_AUTO) [N/y/?]”。如果发现一个git树,修订号将被追加。这个例子中没有使用git,所以我回答"no"。不然git修订号将会追加到版本号中。还记得vmlinuz和几个类似的文件么?好,下一个问题就是问使用哪一种格式压缩内核。开发人员可以从五个选项中选择一个。它们是
|
||||||
|
|
||||||
|
1. Gzip (KERNEL_GZIP)
|
||||||
|
2. Bzip2 (KERNEL_BZIP2)
|
||||||
|
3. LZMA (KERNEL_LZMA)
|
||||||
|
4. XZ (KERNEL_XZ)
|
||||||
|
5. LZO (KERNEL_LZO)
|
||||||
|
|
||||||
|
Gzip是默认值,所以我选择"1"并按回车。每种压缩格式和其他压缩格式相比都有更高或者更低的压缩比。更好的压缩比意味着更小的体积,但是相比低压缩比文件,它解压是需要更多的时间。
|
||||||
|
|
||||||
|
现在这行显示"Default hostname (DEFAULT_HOSTNAME) [(none)]".这可以配置主机名。通常地,开发者这行留空(我这里留空)为了以后Linux用户可以自己设置他们的主机名。
|
||||||
|
|
||||||
|
接下来开发者可以启用或者禁用交换空间。Linux使用独立的分区叫做"swap space"来使用虚拟内存。这相当于Windows中的页面文件。典型地,开发者在这行“Support for paging of anonymous memory (swap) (SWAP) [Y/n/?]”回答是.
|
||||||
|
|
||||||
|
接下来一行(System V IPC (SYSVIPC) [Y/n/?])来询问内核是否支持IPC。进程间通信使进程间可以通信和同步。最好启用IPC不然许多程序将无法工作。这个问题回答是会是配置工具接下来问"POSIX Message Queues (POSIX_MQUEUE) [Y/n/?]".这个问题只会在IPC启用后看见。POSIX消息队列是一种给每条消息一个优先级的消息队列(一种进程间通信形式)。默认的选择是'是'.按回车选择默认选择(以大写选择指示).
|
||||||
|
|
||||||
|
下一个问题(open by fhandle syscalls (FHANDLE) [Y/n/?])是问当有需要进行文件系统操作的时候程序是否允许使用文件句柄而不是文件名进行。默认上,这个选择是'是'。
|
||||||
|
|
||||||
|
有时,开发这在做了一些选择后,某些问题会自动回答。比如,下一个问题(Auditing support (AUDIT) [Y/?])会在没有提示的情况下自动回答因为先前的选项需要这个特性。审计支持会记录所有文件的访问和修改。下一个关于审计的问题(Enable system-call auditing support (AUDITSYSCALL) [Y/n/?]).如果启用,所有的系统调用都会记录下来。如果开发者想要更好的性能,那么最好尽可能地禁用审计特性并不把它加入内核。一些开发者可能为了安全监控而启用审计。这个问题我选择"no".下一个审计问题(Make audit loginuid immutable (AUDIT_LOGINUID_IMMUTABLE) [N/y/?])是询问进程是否可以改变它们的loginuid(LOGIN User ID),如果启用,用户空间中的进程将无法改变他们的loginuid。为了更好的性能,我们这里禁用这个特性。
|
||||||
|
|
||||||
|
注意:当通过"make config"配置时,这些通过配置工具回答的问题会显示出来但是用户无法改变答案。当通过"make menuconfig"配置时,无论用户按任何键都无法改变选项。开发者不想像这样改变选项因为前一个选择取决于另外一个问题的选择。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-1.4274/
|
||||||
|
|
||||||
|
译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user