Linux Kernel in a Nutshell 笔记(一)

2.Requirements for Building and Using the Kernel

注意:
1.在编译内核的过程中,从 downloading 到 uncompress 到 configure 以及 build 务必不要使用 root,只有在 install 器件的两三个命令需要用到 root 权限。
2.kernel 的源代码不要放在 /usr/src/ 目录下,该目录下是放置一些头文件以及系统库文件的地方,另外,开发啥的也不要在此目录下进行。

编译一个 kernel,无外乎这三个工具。

compiler,一般情况下就是 gcc 了:
$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

linker,binutils 工具包包含链接需要的工具:
$ ld -v
GNU ld (GNU Binutils for Ubuntu) 2.20.1-system.20100303

make,一般是在 make 包里面:
$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

对于大部分的程序来说,内核的升级对其没有影响,但是有些系统级别的程序由于内核的升级会产生一些问题,如果升级了内核,这些工具可能也需要升级到对应的版本。

util-linux
跟磁盘相关的,挂载,格式化,硬件时钟等:
$ fdformat --version
fdformat (util-linux-ng 2.17.2)
$ sudo apt-cache show util-linux | head
Package: util-linux
Essential: yes
Priority: required
Section: utils
Installed-Size: 2344
Maintainer: Ubuntu Core Developers <[email protected]>
Original-Maintainer: LaMont Jones <[email protected]>
Architecture: amd64
Version: 2.17.2-0ubuntu1.10.04.2
Replaces: e2fsprogs (<= 1.41.8-1ubuntu1), fdisk, linux32, miscutils, schedutils, setterm, sparc-utils

module-init-tools
跟内核模块相关的,对于 2.6.18 的内核来说,0.9.10 版本是其最老的能够工作的版本,建议升级到新的版本,这样可能带来更多的功能,比如 blacklistint modules 来阻止 udev 来自动加载模块的功能就是新版本才有的:
$ depmod -V
module-init-tools 3.11.1
$ sudo apt-cache show module-init-tools | head
Package: module-init-tools
Priority: required
Section: admin
Installed-Size: 376
Maintainer: Scott James Remnant <[email protected]>
Architecture: amd64
Version: 3.11.1-2ubuntu1
Depends: libc6 (>= 2.8), upstart-job
Breaks: initramfs-tools (<< 0.92bubuntu23)
Filename: pool/main/m/module-init-tools/module-init-tools_3.11.1-2ubuntu1_amd64.deb

filesystem-spceific tools
文件系统相关的

ext 系统的使用 e2fsprogs 这个工具,ext2/ext3/ext4:
$ tune2fs 
tune2fs 1.41.11 (14-Mar-2010)
$ sudo apt-cache show e2fsprogs | head
Package: e2fsprogs
Essential: yes
Priority: required
Section: admin
Installed-Size: 2148
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Theodore Y. Ts'o <[email protected]>
Architecture: amd64
Version: 1.41.11-1ubuntu2.1
Replaces: hurd (<= 20040301-1), libblkid1 (<< 1.38+1.39-WIP-2005.12.10-2), libuuid1 (<< 1.38+1.39-WIP-2005.12.10-2)

JFS
$ fsck.jfs -V
$ sudo apt-cache show  jfsutils | head

Package: jfsutils
Priority: optional
Section: admin
Installed-Size: 1128
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Stefan Hornburg (Racke) <[email protected]>
Architecture: amd64
Version: 1.1.12-2.1
Depends: libc6 (>= 2.7), libuuid1 (>= 2.16-1)
Filename: pool/main/j/jfsutils/jfsutils_1.1.12-2.1_amd64.deb

ReiserFS
$ reiserfsck -V
$ sudo apt-cache show  reiser4progs | head

Package: reiser4progs
Priority: optional
Section: admin
Installed-Size: 1284
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Felix Zielcke <[email protected]>
Architecture: amd64
Version: 1.0.7-5ubuntu1
Depends: libc6 (>= 2.7), libncurses5 (>= 5.6+20071006-3), libreadline6 (>= 6.0), libuuid1 (>= 2.16)
Filename: pool/main/r/reiser4progs/reiser4progs_1.0.7-5ubuntu1_amd64.deb

XFS
$ xfs_db -V
$ sudo apt-cache show  xfsprogs| head

Package: xfsprogs
Priority: optional
Section: admin
Installed-Size: 3412
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Nathan Scott <[email protected]>
Architecture: amd64
Version: 3.1.0ubuntu1
Provides: fsck-backend
Depends: libc6 (>= 2.10), libreadline6 (>= 6.0), libuuid1 (>= 2.16)

Quota
配额相关的:
$ quota -V
$ sudo apt-cache show  quota | head

Package: quota
Priority: optional
Section: admin
Installed-Size: 1468
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Michael Meskes <[email protected]>
Architecture: amd64
Version: 3.17-6
Depends: e2fslibs (>= 1.37), libc6 (>= 2.7), libcomerr2 (>= 1.01), libdbus-1-3 (>= 1.0.2), libldap-2.4-2 (>= 2.4.7), libnl1 (>= 1.1), libwrap0 (>= 7.6-4~), debconf (>= 1.2.9) | debconf-2.0, lsb-base (>= 3.2-13)
Suggests: libnet-ldap-perl, rpcbind | portmap

NFS
网络文件系统,主要是 nfs-common 这个包:
$ showmount --version
$ sudo apt-cache show  nfs-common | head

Package: nfs-common
Priority: optional
Section: net
Installed-Size: 632
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Anibal Monsalve Salazar <[email protected]>
Architecture: amd64
Source: nfs-utils
Version: 1:1.2.0-4ubuntu4.2
Replaces: mount (<< 2.13~), nfs-client, nfs-kernel-server (<< 1:1.0.7-5)

udev
设备命名相关的,由于 /dev/ 以来 /sys/,而 /sys/ 会随着内核的升级而经常改变,所以建议使用随 kernel 发行的 udev,2.6.18 的内核的的最老的版本为 081:
$ udevadm  --version
151
$ sudo apt-cache show udev | head
Package: udev
Priority: required
Section: admin
Installed-Size: 1592
Maintainer: Scott James Remnant <[email protected]>
Architecture: amd64
Version: 151-12.3
Replaces: hotplug, ifrename, initramfs-tools (<< 0.040ubuntu1), udev-extras (<= 20090618)
Depends: libacl1 (>= 2.2.11-1), libc6 (>= 2.9), libglib2.0-0 (>= 2.16.0), libselinux1 (>= 1.32), libusb-0.1-4 (>= 2:0.1.12), upstart-job, module-init-tools (>= 3.2.1-0ubuntu3), initramfs-tools (>= 0.92bubuntu63), procps, adduser, util-linux (>> 2.15~rc2)
Suggests: watershed

process tools
查看进程的包:
$ ps --version
procps version 3.2.8
$ sudo apt-cache show procps | head
Package: procps
Priority: required
Section: admin
Installed-Size: 808
Maintainer: Ubuntu Core Developers <[email protected]>
Original-Maintainer: Craig Small <[email protected]>
Architecture: amd64
Version: 1:3.2.8-1ubuntu4.2
Replaces: bsdutils (<< 2.9x-1), watch
Provides: watch