当前位置:首页 » 编程软件 » ubuntu模块编译

ubuntu模块编译

发布时间: 2022-08-15 07:55:47

A. ubuntu 驱动编译无法通过 求神来解决

复制代码
1 #ifndef __KERNEL__
2 # define __KERNEL__
3 #endif
4 #ifndef MODULE
5 # define MODULE
6 #endif
7
8 // 下面的是主要的内容
9 #include <linux/kernel.h>
10 #include <linux/mole.h>
11 #include <linux/init.h>
12
13 MODULE_LICENSE("GPL");
14
15 static int year=2012;
16
17 int hello_init()
18 {
19 printk(KERN_WARNING "Hello kernel, it's %d!\n",year);
20 return 0;
21 }
22
23
24 void hello_exit()
25 {
26 printk("Bye, kernel!\n");
27 }
28
29 // 下面两个为关键的模块函数
30 mole_init(hello_init);
31 mole_exit(hello_exit);
复制代码
如果上面的代码看起来不太熟悉,那么需要查看以下相关的书籍,比如《Linux设备驱动程序,第三版》,也就是大名鼎鼎的LDD;

2、老式驱动模块编译方法:

直接写出make规则到makefile文件中,引用内核体系的头文件路径,举例如下:

复制代码
1 # The path of kernel source code
2 INCLUDEDIR = /media/GoldenResources/linux/linux-2.6.30/include
3
4 # Compiler
5 CC = gcc
6
7 # Options
8 CFLAGS = -D__KERNEL__ -DMODULE -O -Wall -I$(INCLUDEDIR)
9
10 # Target
11 OBJS = hello.o
12
13 all: $(OBJS)
14
15 $(OBJS): hello.c
16 $(CC) $(CFLAGS) -c $<
17
18 install:
19 insmod $(OBJS)
20
21 uninstall:
22 rmmod hello
23
24 .PHONY: clean
25 clean:
26 rm -f *.o
复制代码
这里有我是用的一个linux内核源代码路径:/media/GoldenResources/linux/linux-2.6.30/include ,注意设置到正确的源码路径。

尝试这编译:

复制代码
$make
gcc -D__KERNEL__ -DMODULE -O -Wall -I/media/GoldenResources/linux/linux-2.6.30/include -c hello.c
In file included from /media/GoldenResources/linux/linux-2.6.30/include/linux/kernel.h:11:0,
from hello.c:8:
/media/GoldenResources/linux/linux-2.6.30/include/linux/linkage.h:5:25: fatal error: asm/linkage.h: No such file or directory
compilation terminated.
make: *** [hello.o] Error 1
复制代码

B. ubuntu下如何编译C语言

1、首先打开ubnutu开发环境,直接输入组合键ctrl+alt+t调出命令行界面。

C. 虚拟机中ubuntu12.04下,编译内核模块时报错:make:***无目标. 停止.。。。。Makefile如下:

解除游戏限制一键安装极速版封喉虚拟机下载地址:

D. ubuntu内核编译需要多长时间

在分析linux内核源码的过程中,要是能够修改内核源码并运行修改后的内核,我想肯定是令人高兴的事,哪怕第一次修改仅仅是在启动时打印一行"Hello, Wang Jiankun!",肯定也是令我高兴的。为了能成功编译修改后的内核,今天先编译一遍内核。
为了有一个完整的记录,今天的起点是一台裸机。
1、在裸机上安装一个最小的debian系统
为了能够尽可能清晰的显示编译一个内核所需要的组件,在安装系统时,仅仅安装最小系统,然后需要什么,就使用apt-get安装什么。
使用网络安装,在安装过程中出现Software selection界面时不要选择任何选项,这样安装的系统将是最小的系统。
为了使用ssh远程登录,最小系统安装完成后,要安装ssh服务器并且要设置静态ip地址(debian安装过程中是通过dhcp获取的ip地址)。
2、安装ssh服务器
apt-get install ssh
3、设置静态ip地址
修改文件/etc/network/interfaces,其中蓝色部分是增加的,红色部分是屏蔽掉的,黑色部分是没有变化的。
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
# Wang Jiankun commented the following line
#iface eth0 inet dhcp
# Wang Jiankun added the the following lines
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1
重启系统后,修改将生效。
4、通过wget下载linux内核源码
administrator@wangjk:~/kernel$ wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.19.tar.bz2
5、解压文件linux-2.6.19.tar.bz2
administrator@wangjk:~/kernel$ tar jxf linux-2.6.19.tar.bz2
tar: bzip2: Cannot exec: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors
administrator@wangjk:~/kernel$
看来是没有bzip2这个包,那就安装一个:
apt-get install bzip2
6、安装debian的kernel-package软件包
在安装kernel-package软件包时,最好使用命令:apt-get build-dep kernel-package,而不要使用命令:
apt-get install kernel-package,后者安装的软件包是前者的子集,使用后者安装kernel-package软件包后,执行make menuconfig命令会出现头文件找不到的错误,如下所示:
administrator@wangjk:~/kernel/linux-2.6.19$ make menuconfig
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:105:23: error: sys/types.h: No such file or directory
scripts/basic/fixdep.c:106:22: error: sys/stat.h: No such file or directory
scripts/basic/fixdep.c:107:22: error: sys/mman.h: No such file or directory
scripts/basic/fixdep.c:108:20: error: unistd.h: No such file or directory
scripts/basic/fixdep.c:109:19: error: fcntl.h: No such file or directory
scripts/basic/fixdep.c:110:20: error: string.h: No such file or directory
scripts/basic/fixdep.c:111:20: error: stdlib.h: No such file or directory
scripts/basic/fixdep.c:112:19: error: stdio.h: No such file or directory
主要是因为libc6-dev软件包没有安装。所以即使使用了apt-get install kernel-package还得使用apt-get build-dep kernel-package,不如一次使用apt-get build-dep kernel-package完成方便。
7、安装libncurses5-dev软件包来支持make menuconfig
通过apt-get build-dep kernel-package安装完成kernel-package后,执行make menuconfig仍然报错,如下所示:
administrator@wangjk:~/kernel/linux-2.6.19$ make menuconfig
HOSTCC scripts/kconfig/lxdialog/checklist.o
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:32:20: error: curses.h: No such file or directory
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:97: error: expected specifier-qualifier-list before 'chtype'
scripts/kconfig/lxdialog/dialog.h:187: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:193: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:195: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:196: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:197: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:198: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:200: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:31: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:59: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:95: error: expected ')' before '*' token
[省略其后部分]
原来是最小系统不支持图形的原因,安装libncurses5-dev后即可。
8、将系统的config文件拷贝到内核目录下
cp /boot/config-2.6.18-6-686 ./.config
9、执行make menuconfig
虽然是将原来系统的config文件拷贝过来的,但是如果所以的配置都采用默认的配置仍然会有问题,在我的系统上在加载文件系统时会死掉,所以还是要做必要的配置,主要是将scsi和sata部分编译进内核而不要编译成模块,如下所示:
Device Drivers --->
Serial ATA (prod) and Parallel ATA (experimental) drivers --->
SCSI device support --->
将蓝色两部分级联的选项全部编译进内核(其实没有必要全部,但为了简单起见,暂时这样做)。
10、安装fakeroot软件包
11、编译内核
fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image
12、安装内核
wangjk:/home/administrator/kernel# dpkg -i linux-image-2.6.19_custom.1.0_i386.deb
Selecting previously deselected package linux-image-2.6.19.
(Reading database ... 17679 files and directories currently installed.)
Unpacking linux-image-2.6.19 (from linux-image-2.6.19_custom.1.0_i386.deb) ...
Done.
Setting up linux-image-2.6.19 (custom.1.0) ...
Running depmod.
Finding valid ramdisk creators.
Using mkinitramfs-kpkg to build the ramdisk.
Running postinst hook script /sbin/update-grub.
You shouldn't call /sbin/update-grub. Please call /usr/sbin/update-grub instead!
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.19
Found kernel: /boot/vmlinuz-2.6.18-6-686
Updating /boot/grub/menu.lst ... done
13、重启系统引导新内核后查看版本号
administrator@wangjk:~$ cat /proc/version
Linux version 2.6.19 (root@wangjk) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 SMP Thu May 7 21:52:10 CST 2009
administrator@wangjk:~$
可以看出已经是我编译的内核了。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jiankun_wang/archive/2009/05/04/4147806.aspx

------------------------------------

ubuntu不带linux内核源码,需要自己下载安装。
1,查看自己的内核版本
uname -r
2,查看源内的内核源码类表
apt-cache search linux-source
3,下载安装内核源代码
sudo apt-get install linux-source-2.6.27 //我选的是这一个,自己看着办吧
4,等待........

下载完成后,在/usr/src下会有一个文件名为linux-source-2.6.xx.tar.bz2的压缩
5,解压缩包
tar jxvf linux-source-2.6.27.tar.bz2 //看清自己的版本

解压后会生成一个源代码目录/usr/src/linux-source-2.6.27
6,进入源码目录后,配置文件
make oldconfig
7,生成内核
make
8,疯狂等待,大约1个多小时

9,编译模块
make moles
10,安装模块
make moles_install

大功告成!^_^
下面说一下Makefile文件

$(MAKE) -C $(KERNELDIR) M=$(PWD) moles_install #PWD当前工作目录的变量
obj-m := hello.o
#hello.o是你要生成的驱动,以后可以自己改
KERNELDIR:=/lib/moles/2.6.27-7-generic/build
#这里别抄,写成你自己的版本,这个目录执行了内核源码目录
PWD:=$(shell pwd) #将当前工作目录赋值该PWD
moles:
$(MAKE) -C $(KERNELDIR) M=$(PWD) moles
moles_install:

下面是一个经典的Hello,world!例子自己make一下就行了。
#include <linux/init.h>
#include <linux/mole.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, cruel world!\n");
}
mole_init(hello_init);
mole_exit(hello_exit);

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/unikingest/archive/2009/03/10/3977747.aspx

-----------------------------------------------------------------------------

修改的这篇文章,自己加了几个注意点
http://blog.theosoft.net/article.asp?id=57

第一次的Linux kernel上机内容是编译一个内核。我用的是Ubuntu,有很多地方和其它 Linux不一样,所以就来把我的过程写下来,以后也好有个参照
首先当然是下载内核源代码,如果你要最新的内核,可以去ftp.kernel.org。当然,国内速度可能会很慢。如果你是教育网用户,可以去上海交大的镜像站下载,地址是http://ftp.sjtu.e.cn/sites/ftp.kernel.org/,缺点就是没有最新的内核(更新需要一定的时间)。
==================================================备注
如果是就是编译ubuntu本省自带的内核,只需要
新立得搜索linux souce,下载带ubuntupatch的kernel的source code。
sudo apt-get source linux-source-2.6.27
==================================================备注
我下载的是linux-2.6.19.2.tar.gz可以下到的最新版本了。下完之后当然是解压缩。不过还不能直接编译,因为Ubuntu的默认安装里缺少必要的组建。打开终端,输入一下命令:
sudo -i
apt-get install build-essential kernel-package libncurses5-dev
然后到新立得里把所有以ncurses开头的软件包全部装上,这样就可以开始编译内核了。
先运行以下命令,复制当前内核的配置文件。
cp /boot/config-`uname -r` ./.config
然后
make menuconfig

选择 "Load an Alternate Configuration File",再选择你刚才拷贝过来的.config文件作为配置文件。然后确定。当结束后,你选择退出时,会提示问你 "Do you wish to save your new kernel configuration?"选择yes即可。
接下来就要编译了。输入命令:
make
你也可以将编译任务分成2个线程来执行,只要输入:
make -j2
编译一般需要1~1.5小时左右,就看cpu的性能如何
编译完成后,开始安装:
make mole_install
make install
然后添加引导信息,不过之前还是要装一个组件initramfs-tools,装完以后输入:
mkinitramfs -o /boot/initrd.img-2.X.XX /lib/moles/2.X.XX
==================================================备注
后面的参数不要忘记了,否则启动新内核会出现错误:
WARNING: Couldn’t open directory /lib/moles/2.6.15.7-ubuntu1: No such file or directory
FATAL: Could not open /lib/moles/2.6.15.7-ubuntu1/moles.dep.temp for writing: No such file or directory
==================================================备注
最后打开 /boot/grub/menu.lst
在 ## ## End Default Options ## 下面添加类似下面的两段
title Ubuntu, kernel 2.6.19.2
root (hd0,4)
kernel /vmlinuz-2.6.19.2 root=/dev/hdd6
initrd /initrd.img-2.6.19.2
savedefault
boot

title Ubuntu, kernel 2.6.19.2 (recovery mode)
root (hd0,4)
kernel /vmlinuz-2.6.19.2 root=/dev/hdd6 ro single
initrd /initrd.img-2.6.19.2
boot
注意 root和kernel字段要模仿menu.lst下面已有的内容写。下面是 (hd0,4),那么你也写(hd0,4),下面写root=/dev/hdd6,你也写root=/dev/hdd6,只是内核的版本号改为现在编译的版本号。然后重新启动计算机,在GRUB中选择新内核启动。如果启动失败,你可以重启选择老内核。

E. ubuntu下安装virtualbox-3.2_3.2.6-63112_Ubuntu_lucid_amd64.deb,提示内核模块编译失败

出现这种问题是因为内核头文件包没有安装,用apt-get在线安装这个包就可以了,在错误提示信息里面有说明(log文件里面的说明会更详细)。这个包的名字是以linux-headers开头的,先查询包的完整名字(因为完整名字不同的内核版本都不一样),再用apt-get install来安装。

F. android.mk ubuntu怎么编译

一个Android.mk file用来向编译系统描述你的源代码。具体来说:该文件是GNU Makefile的一小部分,会被编译系统解析一次或多次。你可以在每一个Android.mk file中定义一个或多个模块。每个模块属下列类型之一:
1)APK程序,一般的Android程序,编译打包生成apk文件
2)java库,java类库,编译打包生成jar文件
3) CC++应用程序,可执行的CC++应用程序
4)CC++静态库,编译生成CC++静态库,并打包成.a文件
5)CC++共享库,编译生成共享库(动态链接库),并打包成.so, 有且只有共享库才能被安装/复制到您的应用软件(APK)包中。
(1)先看一个简单的例子:一个简单的"hello world",比如下面的文件:
sources/helloworld/helloworld.c
sources/helloworld/Android.mk
相应的Android.mk文件会像下面这样:

---------- cut here ------------------

普通的.mk一样

=====================================m、mm、mmm编译命令===========================================

android源码目录下的build/envsetup.sh文件,描述编译的命令
- m: Makes from the top of the tree.
- mm: Builds all of the moles in the current directory.
- mmm: Builds all of the moles in the supplied directories.

所以要想使用这些命令,首先需要在android源码根目录执行build/envsetup.sh 脚本设置环境。
m:编译所有的模块
mm:编译当前目录下的模块,当前目录下要有Android.mk文件
mmm:编译指定路径下的模块,指定路径下要有Android.mk文件

下面举个例子说明,假设我要编译android下的hardwarelibhardware_legacypower模块,当前目录为源码根目录,方法如下:
1、. build/envsetup.sh
2、mmm hardware/libhardware_legacy/power/
或者 :
1、. build/envsetup.sh
2、cd hardware/libhardware_legacy/power/
3、mm

m没有试过。默认上述两个编译命令,只编译发生变化的文件。如果要编译模块的所有文件,需要-b选项,例如mm -b或者mmm -b

make命令,也可以用来编译。如果是include $(BUILD_PACKAGE),用makeLOCAL_PACKAGE_NAME值;如果是include $(BUILD_EXECUTABLE)或者include $(BUILD_JAVA_LIBRARY),用makeLOCAL_MODULE值(未验证)。

G. ubuntu怎么编译nginx

先解压nginx的tar包,进入解压后的文件夹里,如果要安装到其他路径的话,修改configure文件里的prefix的值然后执行./configure,或者直接使用./configure --prefix=/xx/xx/xxx来指定,安装路径然后make -j2,如果你的处理器核多,可以增大数字,再然后就是make & make install了。
要注意的是./configure后面可以跟随很多参数配置:
比如,需要的话可以加上--config-path=/xx/xx/xxx/nginx.conf指定nginx的服务器配置文件路径;
--add-mole增加模块,比如luz、pagespeed、upstream等等,这些都可以在官网上查到。

H. ubuntu 环境下怎样编译pixhawk px4源码

Ubuntu环境下Pixhawk原生固件PX4的编译
分类:无人机ubuntu代码编译Pixhawk
(3946) (6)
Ubuntu下Pixhawk原生固件PX4的编译这个问题困扰了两天时间,可能是博主脑力不够,主要是环境搭建不起来,主要原因应该是路径的原因,最后在大师傅的帮助下还好成功将路径搭建好,成功编译。

下面就跟大家分享一下环境搭建的过程。

1.操作环境

每次写文章,环境一定要介绍的,不同的环境总会出现不同的问题

我的环境是Windows下面安装虚拟机,虚拟机跑Ubuntu

Windows:win10 64位

虚拟机:VMware Workstation 12 Pro 12.1.0 build-3272444

Ubuntu:Ubuntu15.10

2.编译环境搭建

(1)权限设置

官方提示:

Warning Never ever fix permission problems by using 'sudo'. It will create more permission problems in the process and require a system reinstallation to fix them.
意思是你会遇到权限问题,不要用sudo解决,那样会带来更多问题,但是我没听他的,我没用,最后也是实现了

官方提供指令

[plain] view plain

然后注销,重新登录生效

(2)安装

更新包列表,安装下面编译PX4的依赖包。PX4主要支持的系列:

NuttX based hardware: Pixhawk, Pixfalcon
Snapdragon Flight hardware: Snapdragon
Raspberry Pi hardware: Raspberry Pi 2
Host simulation: jMAVSim SITL and Gazebo SITL

注意:安装Ninja Build System可以比make更快进行编译。如果安装了它就会自动选择使用它进行编译。

[plain] view plain
卸载模式管理器

[plain] view plain

更新包列表和安装下面的依赖包。务必安装指定的版本的包

[plain] view plain

上面代码中红色部分大家需要一高警惕,gcc-arm-none-eabi版本导致PX4/Firmware编译错误,现在apt-get安装的gcc-arm-none-eabi基本上是4.9的版本,但是这个固件需要gcc-arm-none-eabi 4.8de 版本,所以最后安装好以后,查看你的gcc-arm-none-eabi版本,如果是4.9需要手动安装4.8的版本,安装gcc-arm-none-eabi 4.8的版本的方法如下:

[plain] view plain

【Warning】上面红色的路径一定要添加正确,不然问题很多,我第一次就输入错误,结果结果开不了机了,反复输入密码。博主装的是Ubuntu 64位系统,而上述arm-none-eabi是直接下载的编译好的32位,还需要安装一个东西
[plain] view plain
可以检查arm-none-eabi 4.8.4是否安装成功,输入以下指令:

[plain] view plain
如果出现如上信息,交叉编译环境搭建就搭建成功了
(3)代码编译
根据PX4中文维基官网教程。
安装Git

[plain] view plain
下载代码

[plain] view plain
初始化
先进入Firmware文件夹,进而进行初始化、更新子模块操作,耐心的等待……

[plain] view plain
权限
编译时会遇到权限问题,执行指令

[plain] view plain
-R 是对文件下面包含的子文件权限问题,* 是对所有文件的权限问题
编译

[plain] view plain
注意到“make”是一个字符命令编译工具,“px4fmu-v2”是硬件版本,“default”是默认配置,所有的PX4编译目标遵循这个规则。
最后附一张编译成功的代码,如果这样你还有问题,请给我留言。

[plain] view plain
-- nuttx-px4fmu-v2-default
-- The ASM compiler identification is GNU
-- Found assembler: /opt/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi-gcc
-- Found pythonInterp: /usr/bin/python (found version "2.7.10")
-- Using C++03
-- Release build type: RelWithDebInfo
-- Adding UAVCAN STM32 platform driver
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lihongwei/Documents/Firmware/build_px4fmu-v2_default
#+@Tools/check_submoles.sh
PX4 CONFIG: px4fmu-v2_default
Scanning dependencies of target git_mavlink
Scanning dependencies of target git_uavcan
Scanning dependencies of target git_gencpp
Scanning dependencies of target git_genmsg
[ 0%] Generating git_init_mavlink_include_mavlink_v1.0.stamp
[ 0%] Generating git_init_src_moles_uavcan_libuavcan.stamp
[ 0%] Generating git_init_Tools_genmsg.stamp
[ 0%] Generating git_init_Tools_gencpp.stamp
[ 0%] Built target git_uavcan
[ 0%] Built target git_mavlink
[ 0%] Built target git_genmsg
[ 0%] Built target git_gencpp

I. ubuntu下怎么编译linux内核

Ubuntu 系统
1. 准备工作
切换为管理员权限,sudo –i 输入用户密码 进入root 权限
apt-get install build-essential kernel-package libncurses5-dev libqt3-headers
build-essential (基本的编程库(gcc, make 等)
kernel-package (Debian 系统里生成 kernel-image 的一些配置文件和工具)
libncurses5-dev (meke menuconfig 要调用的)
libqt3-headers (make xconfig 要调用的)
2. 下载特定版本的内核源代码
3. 复制源码linux-3.2.12.tar.bz2 到/usr/src 目录,解压缩
命令.假设源码存放在/home 目录下
cp /home/linux-3.2.12.tar.bz2 /usr/src
cd /usr/src
tar xvjf linux-3.2.12.tar.bz2
解压后生成 linux-3.2.12 目录
4. cd linux-3.2.12
接下来配置内核选项
make menuconfig 这一步比较复杂,内核选项很多,可以使用当前内核的配置选项,
但编译内核的时间会比较长,因为装系统的时候使用的配置是适应大多数系统的,非定
制选项。关于内核配置选项怎么定制,网上很多。
5. 把正在使用系统中的内核配置文件/usr/src/linux-headers-2.6.38-13-generic/.config 拷到
/usr/src/linux-3.2.12 目录下
cp /usr/src/ linux-headers-2.6.38-13-generic/.config /usr/src/ linux-3.2.12
执行:
cd /usr/src/ linux-3.2.12
make menuconfig
终端会弹出一个配置界面
注意主菜单最后有两项:
load a kernel configuration…
save a kernel configuration…
先选第一项load ….,意思是,利用当前的内核配置详单来设置将要编译的内核,然后选save 这一项保存,最后退出配置界面
6. 开如编译安装新内核
执行:make mrproper (清除以前曾经编译过的旧文件,如果是第一次编译,可不执行)
执行:make (编译,加-j4,必须加,双核并行编译,速度快很多,不过使用原先配置
选项)
然后:make install
再:make moles (编译模块)
再:make moles_install (安装模块)
最后创建initrd 文件:
mkinitramfs -o /boot/initrd.img-linux-3.2.12
7. make install 以后,系统自动更新了启动项,可以cat /boot/grub/grub.cfg 看下.之前的启动项不能删除,如果编译内核不成功,之前的启动项又不见了,系统也就跪了
8. reboot

J. Ubuntu虚拟机里怎么编译内核

方法/步骤
”Ctrl+Alt+T”进入终端,使用命令 sudo passwd root 启动root账号,重启,使用 su 命令获得root权限;

安装编译内核所需软件包
# apt-get update
# apt-get install build-essential kernel-package libncurses5-dev fakeroot 选择Y
下载3.19.3源码包并解压
# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.3.tar.xz
# tar -Jxvf linux-3.19.3.tar.xz
配置内核
# cd linux-3.19.3 (cd命令进入源码目录)
# make mrproper (得到源代码后,将其净化)
# make menuconfig (对内核选项进行配置,不需要配置,直接enter)
# cp /boot/config-'uname -r'-generic ./.config ('uname -r'-generic指现版本内核)
# make clean (删除配置时留下的一些不用的文件)
编译内核(需要很长时间,我用了有两小时,请耐心等待)
# make bzImage
# make moles (编译模块)
安装新内核
# make moles_install (安装模块)
# make install
制作启动盘
# sudo mkinitramfs 3.19.3 -o /boot/initrd.img-3.19.3
更新grub2
# sudo update-grub2

重启,使用新内核(不是注销哦,是重启)
使用命令# uname -r 查看内核版本

热点内容
个性网源码 发布:2025-02-07 13:49:42 浏览:473
sql连接update 发布:2025-02-07 13:46:33 浏览:575
数据库导出sql语句 发布:2025-02-07 13:45:26 浏览:148
traceandroid 发布:2025-02-07 13:43:05 浏览:882
微信公众平台开发java 发布:2025-02-07 13:31:13 浏览:935
中国红网格解压视频 发布:2025-02-07 13:28:48 浏览:862
c语言软件源代码 发布:2025-02-07 13:28:44 浏览:186
2016php 发布:2025-02-07 13:24:10 浏览:327
昱科环球存储科技深圳有限公司 发布:2025-02-07 13:22:49 浏览:895
安卓平板生产力如何 发布:2025-02-07 13:07:20 浏览:350