虚拟机Ubuntu9.10下编译内核

我编译的是在Ubuntu9.10下编译 Linux-2.6.33内核(原来内核Linux-2.6.31.……)

 

 

 


首先需要前期准备,由于Ubuntu没有相关的编译工具,所以应该先安装Vim,build-essential,ncurses-dev这几个工具

前期准备:
1. 安装编译器(这其实是一个开发工具包)
    sudo apt-get install build-essential

2. 安装nurse(运行 menuconfig 必需)
    sudo apt-get install ncurses-dev

3. 下载 Linux 内核源码
     www.kernel.org

编译需要使用管理员权限,所以使用命令:
    sudo -i

 

 

 

切换至管理员模式下。

1. 先复制到目录 /usr/src下

    cp linux-2.6.33.tar.bz2 /usr/src 
    cd /usr/src

2. 解压Linux内核源码:

  现在解压我们下载的源程序文件。如果所下载的是.tar.gz(.tgz)文件,请使用下面的命令:
    tar xzvf linux-2.6.33.tar.gz

  如果你所下载的是.bz2文件,例如linux-2.4.0test8.tar.bz2,请使用下面的命令
    tar xjvf linux-2.6.33.tar.bz2

3.保存当前的配置文件
    cp /boot/config-2.6.31 .config

 

 


接下来的内核配置过程比较烦琐,但是配置的适当与否与日后Linux的运行直接相关,有必要了解一下一些主要的且经常用到的选项的设置。
  配置内核可以根据需要与爱好使用下面命令中的一个:

#make config(基于文本的最为传统的配置界面,不推荐使用)
#make menuconfig(基于文本选单的配置界面,字符终端下推荐使用)
#make xconfig(基于图形窗口模式的配置界面,Xwindow下推荐使用)
#make oldconfig(如果只想在原来内核配置的基础上修改一些小地方,会省去不少麻烦)

个人是使用了make menuconfig
我自己第一次试着修改了这个
Processor type and features
    Timer frequency ->1000

相关配置选项,可以查考http://www.svn8.com/shouce/Linux/kernel_options.html

 

 


配置完以后开始编译了,这三步分别都相当的漫长,可以做做其他事,总共起码一个半小时以上


1)编译内核

    make -j<n> bzImage

<n>替换成数字,代表需要将编译过程拆分成多少个作业。如需要衍生出2个编译作业,则命令为:make -j2 bzImage。在实际中,每个处理器上一般衍生出一个或者两个作业,如果你的机器是双核的,可以将 n 设置成 4 试下。

2)编译模块

    make -j<n> modules

4. 安装

1)模块的安装是自动的,只需运行命令:

    make -j<n> modules_install

即可。

 

 

然后是内核安装

内核的安装稍比较麻烦,首先拷贝编译的文件,依次执行以下命令:

    cp .config /boot/config-2.6.33

    cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.33

    cp System.map /boot/System.map-2.6.33

    mkinitramfs -o /boot/initrd.img-2.6.33 2.6.33

 

 

最后这个步骤就相当的戏剧化

关于启动内核,由于我在虚拟机上测试的,所以这个Ubuntu进入系统时没有Grub的选择,所以当时我就先重新安装了Grub
    sudo apt-get install grub

然后发现已经原有安装了grub-pc,所以又再重新安装grub-pc,在安装的过程中,他把我放在boot目录下的镜像关联了,所
以我重启Ubuntu时,已经可以使用Linux-2.6.33,不过不能选择原来的Linux-2.6.31,还有就是开机是有点怪的现象

转载于:https://www.cnblogs.com/VRS_technology/archive/2010/05/12/1733608.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Foreword by Jack W. Crenshaw (the package’s readme.txt) TUTOR.ZIP This file contains all of the installments of Jack Crenshaw’s tutorial on compiler construction, includ- ing the new Installment 15. The intended audience is those folks who are not computer scientists, but who enjoy computing and have always wanted to know how compilers work. A lot of compiler the- ory has been left out, but the practical issues are covered. By the time you have completed the series, you should be able to design and build your own working compiler. It will not be the world’s best, nor will it put out incredibly tight code. Your product will probably never put Borland or MicroSoft out of business. But it will work, and it will be yours. A word about the file format: The files were originally created using Borland’s DOS editor, Sprint. Sprint could write to a text file only if you formatted the file to go to the selected printer. I used the most common printer I could think of, the Epson MX-80, but even then the files ended up with printer control sequences at the beginning and end of each page. To bring the files up to date and get myself positioned to continue the series, I recently (1994) converted all the files to work with Microsoft Word for Windows. Unlike Sprint, Word allows you to write the file as a DOS text file. Unfortunately, this gave me a new problem, because when Word is writing to a text file, it doesn’t write hard page breaks or page numbers. In other words, in six years we’ve gone from a file with page breaks and page numbers, but embedded escape sequences, to files with no embedded escape sequences but no page breaks or page numbers. Isn’t progress wonderful? Of course, it’s possible for me to insert the page numbers as straight text, rather than asking the editor to do it for me. But since Word won’t allow me to write page breaks to the file, we would end up with files with page numbers that may or may not fall at the ends of the pages, depending on your editor and your printer. It seems to me that almost every file I’ve ever downloaded from CompuServe or BBS’s that had such page numbering was incompatible with my printer, and gave me pages that were one line short or one line long, with the page numbers consequently walking up the page. So perhaps this new format is, after all, the safest one for general distribution. The files as they exist will look just fine if read into any text editor capable of reading DOS text files. Since most editors these days include rather sophisticated word processing capabilities, you should be able to get your editor to paginate for you, prior to printing. I hope you like the tutorials. Much thought went into them. Jack W. Crenshaw
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值