linux内核编译
2012-10-28 10:19
183 查看
以前编过好几次内核都没成功,这次终于通过了,虽然还有些小问题。
where x.y.z is actual version number. For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version. Use wget command to download kernel source code:
$ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
$ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.For example make menuconfig command launches following screen:
Install kernel modules (become a root user, use su command):
config-2.6.25
vmlinuz-2.6.25//**
Linux kernel article and Compiling Linux Kernel module
only.
Official README file has more information on kernel and software requirement to compile it. This file is kernel source directory tree.
Documentation/ directory has interesting kernel documentation for you in kernel source tree.
Step # 1 Get Latest Linux kernel code
Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2,where x.y.z is actual version number. For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version. Use wget command to download kernel source code:
$ cd /tmp $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2Note: Replace x.y.z with actual version number.//**就是在网站上下载最新版本或者需要版本的内核源代码以前编过好几次内核都没成功,这次终于通过了
Step # 2 Extract tar (.tar.bz3) file
Type the following command:# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src # cd /usr/src//**
解压到/usr/src
Step # 3 Configure kernel
Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.# apt-get install gccNow you can start kernel configuration by typing any one of the command:$ make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
$ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
$ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.For example make menuconfig command launches following screen:
$ make menuconfigYou have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.//**gcc一般在安装fedora的时候已经装了,好像xconfig和gconfig都用不了,不晓得为什么。
Step # 4 Compile kernel
Start compiling to create a compressed kernel image, enter:$ makeStart compiling to kernel modules:
$ make modules
Install kernel modules (become a root user, use su command):
$ su -# make modules_install//**
编译内核
Step # 5 Install kernel
So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.# make installIt will install three files into /boot directory as well as modification to your kernel grub configuration file:System.map-2.6.25
config-2.6.25
vmlinuz-2.6.25//**
我编的时候没生成config文件,可能是配置内核的时候没做什么改动都用到默认配置,不过也没关系,系统照样跑起来了
Step # 6: Create an initrd image
Type the following command at a shell prompt:# cd /boot# mkinitrd -o initrd.img-2.6.25 2.6.25initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.//**系统里面找不到mkinitrd命令,直接把原有内核到img文件改个名字也可以用,或者安装mkinitrd:"yum install mkinitrd",img好像是引导时分配内存的吧
Step # 7 Modify Grub configuration file - /boot/grub/menu.lst
Open file using vi:# vi /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.25 Default root (hd0,0) kernel /boot/vmlinuz root=/dev/hdb1 ro initrd /boot/initrd.img-2.6.25 savedefault bootRemember to setup correct root=/dev/hdXX device. Save and close the file. If you think editing and writing all lines by hand is too much for you, try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type the command:
# update-grubNeat. Huh?
Step # 8 : Reboot computer and boot into your new kernel
Just issue reboot command:# rebootFor more information see:Our Exploring
Linux kernel article and Compiling Linux Kernel module
only.
Official README file has more information on kernel and software requirement to compile it. This file is kernel source directory tree.
Documentation/ directory has interesting kernel documentation for you in kernel source tree.
删除内核
查当前使用的内核版本使用命令uname -r就可以了如果想查看所有可用的内核, 大概应该看看 /boot 目录或者 /lib/modules 目录只要系统中至少有一套可用的内核存在, 将其它的删除是没有关系的. 用 apt-get 安装的直接 remove 就可以了, 自己编译的删了就行, 一般来说要删除 /lib/modules 下的相关目录, /boot 下的带相关版本号的所有文件 (注意版本号不只是内核版本号, 还可能有附加信息), 再改一下 /boot/grup/menu.lst 或者 /etc/lilo.conf 就可以了.如果安装了内核源代码, 那么把源代码删了也行, 而且源码是远比编译好的内核及模块占空间的相关文章推荐
- [LINUX问答]内核编译
- S3C2440上移植内核之编译Linux2.6.31出现问题
- LINUX内核编译过程详解[UBUNTU9.04 kernel 2.6.28.9]
- linux 内核配置、编译和制作
- linux下编译新内核,解决无法找到eth0设备问题,安装eth0网卡驱动
- 关于UBOOT,LINUX内核编译,根文件系统的15个问题
- 一个Linux爱好者的2.6.11内核编译过程
- Ubuntu:编译Linux"内核源代码"和"内核模块"
- linux内核编译时用make clean ,make mrproper 还是make distclean
- Ubuntu12.10 内核源码外编译 linux模块--编译驱动模块的基本方法
- Linux内核驱动学习(一)----内核简介 | 配置 | 编译| 安装(PC平台下)
- linux 2.6.30 内核编译 提示 ‘make[1]: *** [arch/x86/vdso/vdso.so.dbg] Error 1’ 错误
- Linux内核编译
- Linux 2.6.34内核编译步骤
- Linux 2.6.19.x 内核编译配置
- linux编译内核
- mini6410基于linux2.6.36内核通过NFS启动根文件系统总结(三编译linux内核)
- Linux 2.6.19.x 内核编译配置选项简介
- 编译 Linux2.6 内核总结
- Linux 自学笔记——内核管理初步及编译