当前位置:首页 » 编程软件 » linux编译好的内核

linux编译好的内核

发布时间: 2022-08-04 06:14:15

⑴ 如何编译linux内核

编译linux内核步骤:
1、安装内核
如果内核已经安装(/usr/src/目录有linux子目录),跳过。如果没有安装,在光驱中放入linux安装光盘,找到kernel-source-2.xx.xx.rpm文件(xx代表数字,表示内核的版本号),比如RedHat linux的RPMS目录是/RedHat/RPMS/目录,然后使用命令rpm -ivh kernel-source-2.xx.xx.rpm安装内核。如果没有安装盘,可以去各linux厂家站点或者www.kernel.org下载。
2、清除从前编译内核时残留的.o 文件和不必要的关联
cd /usr/src/linux
make mrproper
3、配置内核,修改相关参数,请参考其他资料
在图形界面下,make xconfig;字符界面下,make menuconfig。在内核配置菜单中正确设置个内核选项,保存退出
4、正确设置关联文件
make dep
5、编译内核
对于大内核(比如需要SCSI支持),make bzImage
对于小内核,make zImage
6、编译模块
make moles
7、安装模块
make moles_install
8、使用新内核
把/usr/src/linux/arch/i386/boot/目录内新生成的内核文件bzImage/zImage拷贝到/boot目录,然后修改/etc/lilo.conf文件,加一个启动选项,使用新内核bzImage/zImage启动。格式如下:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux-new ### 告诉lilo缺省使用新内核启动linux ###
append="mem=256M"
image=/boot/vmlinuz-2.2.14-5.0
label=linux
read-only
root=/dev/hda5
image=/boot/bzImage(zImage)
label=linux-new
read-only
root=/dev/hda5
保留旧有的启动选项可以保证新内核不能引导的情况,还可以进入linux进行其他操作。保存退出后,不要忘记了最重要的一步,运行/sbin/lilo,使修改生效。
9、重新生成ram磁盘
如果您的系统中的/etc/lilo.conf没有使用了ram磁盘选项initrd,略过。如果您的系统中的/etc/lilo.conf使用了ram磁盘选项initrd,使用mkinitrd initrd-内核版本号,内核版本号命令重新生成ram磁盘文件,例如我的Redhat 6.2:
mkinitrd initrd-2.2.14-5.0 2.2.14-5.0
之后把/etc/lilo.conf中的initrd指向新生成的initrd-2.2.14-5.0文件:
initrd=/boot/initrd-2.2.14-5.0
ram磁盘能使系统性能尽可能的优化,具体参考/usr/src/linux/Documents/initrd.txt文件
10、重新启动,OK!

⑵ 在linux上编译内核

看上去像是 gcc 有问题, 按理它应该调用的是cc去编译,你的不知道为什么在试图使用cc1……

你先用 gcc去尝试编译一个简单的.c文件,比如自己写一个 hello world程序,看看 gcc 能不能编译,如果可以,那么可能是内核makefile的问题,试一下
make mrproper
然后再去 make menuconfig

如果你的hello world程序都没法编译,说明确实是gcc的问题,建议你重新安装gcc,不知道你的linux是什么版本,建议去参考你linux发行版的手册去看如何安装编译环境,防止错漏安装包。 不过还是给你一个非常规的解决方法,进入你gcc安装目录,一般gcc是在 /usr/bin/ 目录下 (可以用 which gcc查看gcc所在目录),然后ls cc 看看,是否存在cc这个文件,如果有,那么 ln -s cc cc1 (要用 root 身份来执行这条命令), 然后再去试试 gcc,应该不报错了吧。

上面给你的这个非常规解决方法可能只能解决你提出的这个问题,但是如果你gcc安装的有问题,缺了什么东西了话,这个方法解决了这个问题,你肯定还会遇到其他问题的,建议还是按照正规方式安装gcc及其相关依赖包。

⑶ linux编译好了内核,也编译好了内核模块,最后内核放在fllash中,内核模块放哪里

问题补充:如题了,linux模块编程为什么要编译内核源码树。以及为什么内核版本当然需要。。。 第一点,就是源码树中有相应的头文件和函数的实现,没有

⑷ linux内核编译的几点疑惑

1.不一定是升级。一般编译内核有升级某些特性修正一些bug,但是也有精简来适应自己的机子硬件。
2.编译成功后的内核与原来内核没有影响(除非将原来的覆盖),原来的内核最好保留,避免新内核运行不成功。
3.编译的新内核主要看你自己在config文件上的配置。

⑸ 关于Linux内核编译,如果我已经编译好内核,那么下一步怎么办,如何用它替换我现在已经装好的linux的内核

RH9 不要折腾了,你升级了内核也没有意义。

⑹ linux如何编译安装新内核支持NTFS文件系统(

第一步: 对硬件进行设置,使其满足要求并下载内核:

1. 新添加一块20G的硬盘及修改内存:

⑺ 编译好的Linux0.11内核 如何运行

你还需要准备一个initrd,然后使用qemu的命令启动,使用你的image和initrd,配置好参数就可以了。system.map启动不需要

⑻ Linux 2.6.34内核编译

Linux-2.6.34内核编译指南
2010-06-11 22:45 作者:玮琦 页面排版:玮琦

对linux内核的编译来说是每个编译者都必须掌握的一个阶段,但是编译内核是有相对一些难度的,也许你可能不知如何着手,请不必为此烦恼或者放弃,经过一些归纳和总结我编写了比较详细的步骤,从而可以为广大的爱好者以及新手能带来更好的帮助和深入的了解

一、下载内核
到www.kernel.org 下载新内核到 /usr/src
下载建议最好下载比当前已安装版本高的内核我下载的是 linux-2.6.34.tar.bz2( 原来的内核是 2.6.18-128.e15-i686)
★ 我察看当前内核的版本

[root@localhost~]#uname -a
Linux localhost.localdomain 2.6.18-128.e15-i686 #1 SMP Tue Jun 8 10:30:55 CST 2010 i686 i686 i386 GNU/Linux
然后将其解压到/usr/src目录下,使用下面的命令解压得到linux-2.6.34:
[root@localhost~]#tar -jxvf linux-2.6.34.tar.bz2
[root@localhost~]#bzip2 -d linux-2.6.34.tar.bz2

如果所下载的是.tar.gz(.tgz)文件,请使用下面的命令:

[root@localhost~]#tar -zxvf linux-2.6.34.tar.gz

为了不把原来的目录覆盖掉所以呢在当前路径下做一个链接为linux:

[root@localhost~]#ln -s /usr/src/linux-2.6.34 /usr/src/linux

二、配置内核
[root@localhost~]#make clean 清除原有不需要的模块和文件(垃息)
[root@localhost~]#make mrproper 清理源代码数
[root@localhost~]#make menuconfig 基于ncurse的图形配置界面,可以在文本下以菜单方式,进行配置。
Load an Alternate Configuration File,导入.config文件
注:内核配置有两种方法,一种是直接置入内核* ;另一种是编成模块M ;两种方法各有优点;直接编入内核的,比如设备的启动,不再需要加载模块的这一过程了;而编译成模块,则需要加载设备的内核支持的模块;但直接把所有的东西都编入内核也不是可行的,内核体积会变大,系统负载也会过重。我们编内核时最好把极为重要的编入内核;其它的如果您不明白的,最好用默认.
移动键盘上下左右键,按Enter 进入一个目录。把指针移动到Exit就退出当前目录到上级目录;
下面图形界面蓝色区域为选择区:
General setup -→
[*] Enable loadable mole support --->
-*- Enable the block layer -→
Processor type and features --->
Power management and ACPI options --->
Bus options (PCI etc.) --->
Executable file formats / Emulations --->
-*- Networking support --->
Device Drivers -→
Firmware Drivers --->
File systems --->
Kernel hacking -→
Security options --->
-*- Cryptographic API -→
[*] Virtualization -→
Library routines --->
---
Load an Alternate Configuration File
Save an Alternate Configuration File

<Select> < Exit > < Help >

修改完毕选择Save an Alternate Configuration File,然后退出配置
[root@localhost~]#cp ../kernels/2.6.18-128.e15-i686/.config /usr/src
★ 编辑配置文件.config

[root@localhost~]#vim .config

找到105行的"#CONFIG_SYSFS_DEPRECATED is not set"改为"CONFIG_SYSFS_DEPRECATED=y" 保存
假如不修改该行,在升级重新启动后会报如下的错,导致启动失败

Volume group "VolGroup00" not found

Unalbe to access resume device (/dev/VolGroup00/LogVol00)

mount: could not find filesystem '/dev/root'

setuproot:moving /dev failed: No such file or directory

setuproot:error mounting /proc: No such file or directory

setuproot:error mounting /sys: No such file or directory

switchroot: mount failed: No such file or directory

Kernel panic - not syncing:Attempted to kill init!

★ 编译开始,大概需要半个小时到一个小时的时间自己可以倒杯凉茶耐心候。

[root@localhost~]#make

★ 编译外挂模块和需要加载的模块安装

[root@localhost~]#make moles && make moles_install

这时候会出现3个警告[2]

WARNING: No mole dm-mem-cache found for kernel 2.6.34, continuing anyway

WARNING: No mole dm-message found for kernel 2.6.34, continuing anyway
WARNING: No mole dm-raid45 found for kernel 2.6.34, continuing anyway
经过测试,这3个警告不会影响内核的升级

★ 编译系统内核且生成新的内核文件

[root@localhost~]#make bzImage

[root@localhost~]#cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.34

[root@localhost~]#mkinitrd /boot/initrd-2.6.34.img 2.6.34

[root@localhost~]# cp /boot/initrd-2.6.34.img /tmp

[root@localhost~]#cd /tmp/

[root@localhost~]#ls

[root@localhost~]#initrd-2.6.34.img

[root@localhost~]#mkdir newinitrd

[root@localhost~]# cd newinitrd/

[root@localhost~]# zcat ../initrd-2.6.34.img |cpio -i

[root@localhost~]# ls

bin dev etc init lib proc sbin sys sysroot

[root@localhost~]#vim init

★ 删掉重复的两行,有些情况下是没有就不要执行

echo "Loading dm-region-hash.ko mole"

insmod /lib/dm-region-hash.ko

echo "Loading dm-region-hash.ko mole"

insmod /lib/dm-region-hash.ko

★ 重新打包initrd

[root@localhost~]# find .|cpio -c -o > ../initrd

[root@localhost~]# cd ..

[root@localhost~]# gzip -9 < initrd > initrd-2.6.34.img

★ 将initrd重新复制到/boot目录下

[root@localhost~]#cp initrd-2.6.34.img /boot

★ 给 /boot/grub/grub.conf中添加一个新的启动项,

[root@localhost~]#vim /boot/grup/grup.conf

如我的 grub.conf 增加了
如下一段文字
title Red Hat(2.6.34)
root (hd0,5)
kernel /boot/vmlinuz-2.6.34 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.34.img

三、重新起动
[root@localhost~]# reboot
★ 启动成功后查看当前内核版本号

[root@localhost~]#uname -r
2.6.34
四、待解决的问题

★ Iptables启动失败

操作系统启动过程中出现下面的错误信息:

Applying ip6tables firewall rules: ip6tables-restore v1.3.5: ip6tables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "ip6tables-restore -h' or 'ip6tables-restore --help' for more information.

Applying iptables firewall rules: iptables-restore v1.3.5: iptables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "iptables-restore -h' or 'iptables-restore --help' for more information.

启动后尝试手动启动防火墙:

[root@localhost~]#service iptables status

防火墙已停

[root@localhost~]#service iptables start

正在卸载 Iiptables 模块:[确定]

应用 iptables 防火墙规则:iptables-restore v1.3.5: iptables-restore: unable to initializetable 'filter'

Error occurred at line: 3

Try `iptables-restore -h' or 'iptables-restore --help' for more information.

[失败]

★ Hidd(Bluetooth HID daemon)启动失败

Starting hidd: Can't open HIDP control socket: Address family not supported by protocol [FAILED]

[root@localhost~]# service hidd status

hidd 已死,但是 subsys 被锁

[root@localhost~]# service hidd start

正在启动 hidd:Can't open HIDP control socket: Address family not supported by protocol

⑼ linux内核编译问题 vmware内编译好内核如何在其他主机上安装

你这水平要加油了。
1. 没有网卡的话,可以增加个usb口的网卡呢。一个才十几块钱。usb口绝对有。配置好ip地址,直接传,如scp.
2. 拷贝内核,moles, 到U盘。
然后目标机器挂载U盘。
dmesg 识别到u盘。
然后挂载u盘:mount挂载下。
然后手动安装内核,生成initxxxx文件,修改bootloader内核优先级。
最后 sync 然后eject弹出u盘即可。
3. 硬盘接口等传文件。
4. 人人顺风顺水的回答没有问题,简明,是你水平太差看不懂而已。
5. 内核目录里有个Documentation, 你多阅读下

⑽ 裸机运行编译好的linux内核!

裸机无法运行单纯的一个linux内核。
但可以最小化的安装linux系统,
这个你可以去了解gentoo archlinux以及终极的LFS

热点内容
Ftp打开文件是只读模式 发布:2025-02-09 07:40:55 浏览:504
androidlistview点击事件 发布:2025-02-09 07:25:52 浏览:171
targz解压缩 发布:2025-02-09 06:59:19 浏览:311
wpsphp 发布:2025-02-09 06:58:41 浏览:961
视易锋云系统如何架设辅助服务器 发布:2025-02-09 06:47:08 浏览:770
mysql备份脚本shell 发布:2025-02-09 06:46:33 浏览:15
腾讯云服务器怎样调整分辨率 发布:2025-02-09 06:46:30 浏览:369
php上一个页面 发布:2025-02-09 06:41:25 浏览:489
改装配置后不想重启怎么办 发布:2025-02-09 06:36:40 浏览:446
算法复杂度定义 发布:2025-02-09 06:30:46 浏览:587