Linux源码-用户和管理员手册-release 4.x

阅读数:144 评论数:0

跳转到新版页面

分类

Linux

正文

一、安装内核源码

如果你安装全部的sources,把内核tarball放在你有权限的目录下,解压缩,不要使用/usr/src/linux这个目录,因为这是linux系统使用的目录。

xz -cd linux-4.X.tar.xz | tar xvf -

你也可以在4.x系列中通过补丁升级。补丁是xz格式,下载所有的补丁文件,如果要移除backup文件(some-file-name~或者some-file-name.orig),确保没有失败的补丁(some-file-name#或some-file-name.rej)。和为4.x内核打补丁不同,为4.x.y内核打补丁不是递增的,而是直接基于4.x内核进行。如果你当前内核是4.0,想应用4.0.3补丁,你一定要先应用4.0.1和4.0.2补丁,如果当前内核是4.0.2,想应用4.0.3补丁,你一定要先回退到4.0.2补丁(patch -R),然后再应用4.0.3补丁。可以使用内核补丁脚本来自动化这个过程。

xz -cd ../patch-4.x.xz | patch -p1

linux/scripts/patch-kernel linux

确保你没有stale.o文件和相关依赖

cd linux
make mrproper

现在你应该已经正确安装了源码。

二、软件要求

编译和运行4.x内核,对软件包有最低版本有求。

Program Minimal version Command to check the version
GNU C 3.2 gcc –version
GNU make 3.81 make –version
binutils 2.20 ld -v
flex 2.5.35 flex –version
bison 2.0 bison –version
util-linux 2.10o fdformat –version
module-init-tools 0.9.10 depmod -V
e2fsprogs 1.41.4 e2fsck -V
jfsutils 1.1.3 fsck.jfs -V
reiserfsprogs 3.6.3 reiserfsck -V
xfsprogs 2.6.0 xfs_db -V
squashfs-tools 4.0 mksquashfs -version
btrfs-progs 0.18 btrfsck
pcmciautils 004 pccardctl -V
quota-tools 3.09 quota -V
PPP 2.4.0 pppd –version
isdn4k-utils 3.1pre1 isdnctrl 2>&1|grep version
nfs-utils 1.0.5 showmount –version
procps 3.2.0 ps –version
oprofile 0.9 oprofiled –version
udev 081 udevd –version
grub 0.93 grub –version || grub-install –version
mcelog 0.6 mcelog –version
iptables 1.4.2 iptables -V
openssl & libcrypto 1.0.0 openssl version
bc 1.06.95 bc –version
Sphinx[1] 1.3 sphinx-build –version

三、内核的编译目录 

当编译内核时,生成文件默认与源文件保存的一起,使用make O=output/dir选项可以指定生成文件的存放目录。

例如:

kernel source code: /usr/src/linux-4.X
build directory: /home/name/build/kernel

那么可以这样配置:

cd /usr/src/linux-4.X
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install

如果使用的了O=output/dir选项,那么所有的make必须都要使用。

四、配置内核

1、make config, plain text interface

2、make menuconfig , text based color menus, radiolists & dialogs

3、make nconfig , enhanced text based color menus

4、make xconfig, qt based configuration tool

5、make gconfig, gtk+ based configuration tool

6、make oldconfig, default all questions based on the contents of your existing ./.config file and asking about new config symbols

7、make olddefconfig, lkie above , but sets new symbols to their default values without prompting.

8、make defconfig, create a ./.config file by using the default symbol values from either arch/$ARCH/defconfig or arc/$ARCH/configs/${PLATFORM}_defconfig, depending on the architecture.

9、make ${PLATFORM}_defconfig, create a ./.config file by using default symbol values from arch/$ARCH/configs/${PLATFORM}_defconfig

10、make allyesconfig, create a ./.config file by setting symbol values to 'y' as much as possible

11、make allmodconfig, create a ./.config file by setting symbol values to 'm' as much as possible

12、make allnoconfig , create a ./.config file by setting symbol values to 'n' as much as possible

13、make randconfig, create a ./.config file by setting symbol values to random values

14、make localmodconfig,  create a config based on current config and loaded modules (lsmod), Disables any module option that is not needed for the loaded modules.

To create a localmodconfig for another machine,
store the lsmod of that machine into a file
and pass it in as a LSMOD parameter.

target$ lsmod > /tmp/mylsmod
target$ scp /tmp/mylsmod host:/tmp

host$ make LSMOD=/tmp/mylsmod localmodconfig

The above also works when cross compiling.

15、make localyesconfig, similar to localmodconfig, except it will convert all module options to built in (=y) options

16、make kvmconfig, Enable additional options for kvm guest kernel support

17、make xenconfig, enable additional options for xen dom0 guest kernel support

18、make tinyconfig, configure the tinest possible kernel.

五、编译内核

1、执行一个make来创建一个压缩的内核镜像,如果你安装了适配kernel makefiles的lilo,也可以执行make install。编译时不需要root用户,但是安装时需要使用root用户。

2、如果你把内核的部分配置为modules,那么需要执行make modules_install

3、冗长的compile/build 输出。正常情况下,内核编译时处于quiet mode,如果你想看到具体的过程信息,可以使用verbose编译模式,通过给make命令传统V=1,默认V=0,V=2是rebuild of each target。

make V=1 all

4、保留内核的一个backup,以防止出问题。确保也为内核对应的modules也做了backup。可以在内核编译时配置LOCALVERSION选项来为内核版本添加前缀。

5、为了启动新内核,需要把内核镜像拷贝到正常内核加载的地方。

6、内核的加载不再支持从floppy中加载,如果从硬盘中启动Linux,使用LILO,通过/etc/lilo.conf文件来指内核镜像,内核镜像文件通常为/vmlinz, /boot/vmlinuz, /bzImage或/boot/bzImage,为了使用新内核,需要用新内核镜像替换老镜像,然后一定要重新运行LILO。重新安装LILO通常是运行/sbin/lilo,也可以修改/etc/lilo.conf文件。如果需要修改默认的root device ,video mode, ramdisk size等,可以使用rdev程序(或LILO启动参数),而不需要重新编译内核。




相关推荐

一、概述 1、为什么Linus不使用GPLv3 在 PC 上,只要你得到了某个程序的源代码,就可以自行编译生成二进制程序,然后替换掉原有的二进制程序,你的程序自由很容易得到保证。然而 iPod、iPh

说明:这种方式只是用于方便阅读代码,因为可以在源代间快速索引跳跃。但是最后可能会有一些warning,可以不必关心,如果是强迫症,可以使用下面这种方式来去掉。

一、概述 在Linux系统中,/usr/bin和/usr/local/bin是两个常见的目录,用于存放可执行文件(二进制文件)。 很多应用都安装在/usr/local下面,先看一下automake工具

  一、概述 vmstat命令是最常见的Linux/Unix监控工具,可以监控给定时间间隔服务器的CPU使用率、内存使用、IO情况。相比top命令,可以查看到整个机器的CPU、内存、IO的使用情况,而

一、概述 sar,System Activity Reporter。是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况、系统调用的使用情况、磁

一、简介 简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各种分析处理。 二、使用方法 1、基本语法  awk '条件类型1 {动作1} 条件类型2{动作2} ...

一、概述 列出目标目录中所有的子目录和文件。 二、 语法 ls [选项] [目录名] -a, –all 列出目录下的所有文件,包括以 . 开头的隐含文件 -A 同-a,但不列出“.”(表示当前目录)

一、概述 cd全称是change directory,用于切换当前工作目录。 注意的是,cd命令是一个内建命令,它是由 shell 提供的。因此,不同的 shell 可能会有一些差异,但基本的用法和功

一、概述 全称为print working directory,查看”当前工作目录“的完整路径,一般情况下不带任何参数 二、语法 pwd [选项] -L 即logical,逻辑路径 -P 即

一、概述 通过 mkdir 命令可以实现在指定位置创建以 DirName(指定的文件名)命名的文件夹或目录。要创建文件夹或目录的用户必须对所创建的文件夹的父文件夹具有写权限。并且,所创建的文件夹(目录