Version Description
+++-==============-==============-============================================
ii linux-firmware 1.34.1 Firmware for Linux kernel drivers
ii linux-headers- 2.6.32-22.36 Header files related to Linux kernel version
ii linux-headers- 2.6.32-22.36 Linux kernel headers for version 2.6.32 on x
ii linux-image-2. 2.6.32-22.36 Linux kernel image for version 2.6.32 on x86
ii linux-libc-dev 2.6.32-23.37 Linux Kernel Headers for development
。。。。。
可以看出系统安装的与kernel相关的软件包挺多的,但主要有三种类型:
linux-firmware kernel提供的固件程序,位于/lib/firmware目录下。操作系统用驱动程序驱动硬件,而驱动程序就是和硬件上的固件(如PCI设备上的PCI BIOS)进行交互以控制对应硬件的,所以固件是驱动程序与硬件的执行机构间的桥梁。
linux-headers 与特定linux kernel版本相关的头文件,位于/usr/src/linux-headers-2.6.32-22/include和/usr/include目录下,在编译一些modules和软件如virtualbox additional tools 时使用。
linux-image linux kernel的二进制压缩文件即/boot/vmlinu文件,此文件就是大名鼎鼎的linux内核文件!
linux-generic 主要提供相应版本linux kernel的metadata即更新文件
2、让我们重点看一下系统安装的linux-image软件包的功能和内容:
geekard@geekard-laptop:~$ dpkg -s linux-image-2.6.32-22-generic
Package: linux-image-2.6.32-22-generic
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 94652
Maintainer: Ubuntu Kernel Team <[email protected]>
Architecture: i386
Source: linux
Version: 2.6.32-22.36
Provides: fuse-module, ivtv-modules, kvm-api-4, linux-image, linux-image-2.6, ndiswrapper-modules-1.9, redhat-cluster-modules
Depends: initramfs-tools (>= 0.36ubuntu6), coreutils | fileutils (>= 4.0), module-init-tools (>= 3.3-pre11-4ubuntu3), wireless-crda
Pre-Depends: dpkg (>= 1.10.24) #注意这些依赖的软件包的作用是和kernel启动时需要的文件密切相关的。
Recommends: grub-pc | grub | lilo (>= 19.1)
Suggests: fdutils, linux-doc-2.6.32 | linux-source-2.6.32, linux-tools
Breaks: lvm2 (<< 2.02.54-1ubuntu3)
Conflicts: hotplug (<< 0.0.20040105-1)
Description: Linux kernel image for version 2.6.32 on x86/x86_64
This package contains the Linux kernel image for version 2.6.32 on
x86/x86_64.
.
Also includes the corresponding System.map file, the modules built by the
packager, and scripts that try to ensure that the system is not left in an
unbootable state after an update.
.
Supports Generic processors.
.
Geared toward desktop systems.
.
You likely do not want to install this package directly. Instead, install
the linux-generic meta-package, which will ensure that upgrades work
correctly, and that supporting packages are also installed.
geekard@geekard-laptop:~$
geekard@geekard-laptop:~$ dpkg -L linux-image-2.6.32-22-generic
/.
/boot #这就是系统启动目录,其中多是与kernel相关的文件
/boot/vmlinuz-2.6.32-22-generic
/boot/config-2.6.32-22-generic
/boot/abi-2.6.32-22-generic
/boot/System.map-2.6.32-22-generic
/boot/vmcoreinfo-2.6.32-22-generic
/lib
/lib/modules #这就是kernel提供的module所在的目录,在开机过程中和系统运行过程中经常使用。注意module和特定版本的kernel是对应的。
/lib/modules/2.6.32-22-generic
/lib/modules/2.6.32-22-generic/kernel
/lib/modules/2.6.32-22-generic/kernel/arch
/lib/modules/2.6.32-22-generic/kernel/arch/x86/kvm/kvm.ko
…..
/lib/firmware/2.6.32-22-generic/mts_gsm.fw #kernel提供的固件程序
/lib/firmware/2.6.32-22-generic/yam/9600.bin
/usr
/usr/share
/usr/share/doc
/usr/share/doc/linux-image-2.6.32-22-generic
/usr/share/doc/linux-image-2.6.32-22-generic/changelog.Debian.old.gz
/usr/share/doc/linux-image-2.6.32-22-generic/copyright
/usr/share/doc/linux-image-2.6.32-22-generic/changelog.Debian.gz
3、好了,我们现在知道了/boot目录下除grub子目录外的所有文件都是由linux-image软件包提供的,那么这些文件的作用是什么呢?
geekard@geekard-laptop:~$ ls /boot #kernel相关文件
abi-2.6.32-22-generic memtest86+.bin
config-2.6.32-22-generic System.map-2.6.32-22-generic
grub vmcoreinfo-2.6.32-22-generic
initrd.img-2.6.32-22-generic vmlinuz-2.6.32-22-generic
geekard@geekard-laptop:~$
各文件功能如下:
config-2.6.32-22-generic 内核参数配置记录文件,这个文件在重新编译配置kernel时非常有用。
System.map-2.6.32-22-generic 内核对象列表文件,内核对象是内核提供的常量及函数的符号链接
vmcoreinfo-2.6.32-22-generic 内核核心参数设置记录文件
initrd.img-2.6.32-22-generic intrd文件,注意这个和系统的kernel版本是对应的,一般开机时必须在GRUB中指定
vmlinuz-2.6.32-22-generic 内核文件,这个和上个文件即为在GRUB命令行上指定的文件
geekard@geekard-laptop:~$ uname -a #查看系统kernel信息命令
Linux geekard-laptop 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux
geekard@geekard-laptop:~$
显示的含义为:主机名为geekard-laptop、硬件平台为i686的笔记本电脑安装了GNU/Linux 类型的操作系统,其kernel是在SMP Thu Jun 3 22:02:19 UTC 2010第36次编译的,版本为版本为2.6.32-22-generic
另外在系统运行的过程中可以查看和编辑/proc/sys/kernel/下的相应文件,实时获取和设置kernel的参数
geekard@geekard-laptop:~$ ls /etc/kernel #更新内核过程中用到的配置脚本
header_postinst.d postinst.d prerm.d
geekard@geekard-laptop:~$
4、内核的安装方式:
(1)、从配置并编译好的rpm或deb软件包安装。
(2)、从源码包安装,需手动配置。建议高级用户使用,配置不当会造成系统不能正常启动。
从源代码安装的步骤:(以下内容摘自kernel源代码的README文件)
1、INSTALLING the kernel source:
- If you install the full sources, put the kernel tarball in a
directory where you have permissions (eg. your home directory) and
unpack it:
gzip -cd linux-2.6.XX.tar.gz | tar xvf -
or
bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf -
Replace "XX" with the version number of the latest kernel.
2、Make sure you have no stale .o files and dependencies lying around:
cd linux
make mrproper
You should now have the sources correctly installed.
3、CONFIGURING the kernel:
"make config" Plain text interface.
"make menuconfig" Text based color menus, radiolists & dialogs.
"make xconfig" X windows (Qt) based configuration tool.
"make gconfig" X windows (Gtk) based configuration tool.
"make oldconfig" Default all questions based on the contents of
your existing ./.config file and asking about
new config symbols.
在配置kernel时最重要的是确定kernel对芯片组、总线、文件系统的支持。
4、Do a "make" to create a compressed kernel image. It is also possible to do "make install" if you have lilo installed to suit the
kernel makefiles, but you may want to check your particular lilo setup first.
COMPILING the kernel: If you configured any of the parts of the kernel as `modules', you will also have to do "make modules_install".
5、配置grub.cfg文件,在其中添加新配置的kernel及initrd文件作为启动项
6、Reboot with the new kernel and enjoy.