在Nvidia驱动论坛逛的时候,看别人都在用rc(release candidate)了,心又痒了。
以前倒也干过,一有大的变动就等不及先从kernel.org下载源码自己编译安装,因为这发行版很多时候都会慢半拍,更有追求稳定的发行版入centOS现在还是2.6呢。
后来久了,疲劳了,也没见啥变化,就是多了些设备驱动,可是我这笔记本哪有啥新设备,我这配置搁现在都成人家游戏的最低标准了,就不干了,其实用着发行版提供的通用内核也也没啥,稳定。
进入正题
1.笔记本配置和内核模块:
jiawen@acer:~$ lspci
00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 18)
00:01.0 PCI bridge: Intel Corporation Core Processor PCI Express x16 Root Port (rev 18)
00:16.0 Communication controller: Intel Corporation 5 Series/3400 Series Chipset HECI Controller (rev 06)
00:1a.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)
00:1c.1 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 2 (rev 05)
00:1d.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev a5)
00:1f.0 ISA bridge: Intel Corporation Mobile 5 Series Chipset LPC Interface Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller (rev 05)
00:1f.6 Signal processing controller: Intel Corporation 5 Series/3400 Series Chipset Thermal Subsystem (rev 05)
02:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 415M] (rev a1)
02:00.1 Audio device: NVIDIA Corporation GF108 High Definition Audio Controller (rev a1)
03:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)
05:00.0 Network controller: Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express) (rev 01)
ff:00.0 Host bridge: Intel Corporation Core Processor QuickPath Architecture Generic Non-core Registers (rev 05)
ff:00.1 Host bridge: Intel Corporation Core Processor QuickPath Architecture System Address Decoder (rev 05)
ff:02.0 Host bridge: Intel Corporation Core Processor QPI Link 0 (rev 05)
ff:02.1 Host bridge: Intel Corporation Core Processor QPI Physical 0 (rev 05)
ff:02.2 Host bridge: Intel Corporation Core Processor Reserved (rev 05)
ff:02.3 Host bridge: Intel Corporation Core Processor Reserved (rev 05)
其实都没啥特别的,后面配置内核选项的时候用得着,差不多知道有些啥硬件就好。
下面是内核模块,这个有点重要,基本上就是需要加载那些驱动,其实看看也好
jiawen@acer:~$ lsmod
Module Size Used by
btrfs 815968 0
raid6_pq 97812 1 btrfs
zlib_deflate 26885 1 btrfs
xor 21411 1 btrfs
ufs 74590 0
qnx4 13317 0
hfsplus 102646 0
hfs 54590 0
minix 36111 0
ntfs 96882 0
msdos 17332 0
jfs 180909 0
xfs 884143 0
libcrc32c 12615 2 xfs,btrfs
reiserfs 245794 0
ext2 72832 0
vesafb 13828 1
parport_pc 32701 0
ppdev 17671 0
rfcomm 69070 0
bnep 19564 2
bluetooth 371874 10 bnep,rfcomm
snd_hda_codec_hdmi 41276 4
joydev 17377 0
intel_powerclamp 14705 0
coretemp 13435 0
kvm_intel 138538 0
kvm 431315 1 kvm_intel
acer_wmi 32522 0
sparse_keymap 13948 1 acer_wmi
uvcvideo 80885 0
videobuf2_vmalloc 13216 1 uvcvideo
videobuf2_memops 13362 1 videobuf2_vmalloc
videobuf2_core 40469 1 uvcvideo
videodev 133390 2 uvcvideo,videobuf2_core
arc4 12608 2
snd_hda_codec_realtek 51465 1
snd_hda_intel 48171 5
snd_hda_codec 188738 3 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intel
snd_hwdep 13602 1 snd_hda_codec
snd_pcm 102033 3 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel
snd_page_alloc 18710 2 snd_pcm,snd_hda_intel
snd_seq_midi 13324 0
snd_seq_midi_event 14899 1 snd_seq_midi
microcode 23518 0
snd_rawmidi 30095 1 snd_seq_midi
psmouse 97626 0
serio_raw 13413 0
ath9k 151173 0
intel_ips 18470 0
ath9k_common 13859 1 ath9k
ath9k_hw 444645 2 ath9k_common,ath9k
snd_seq 61560 2 snd_seq_midi_event,snd_seq_midi
ath 23827 3 ath9k_common,ath9k,ath9k_hw
snd_seq_device 14497 3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer 29433 2 snd_pcm,snd_seq
mac80211 596969 1 ath9k
nvidia 10576654 43
lpc_ich 21080 0
cfg80211 479757 3 ath,ath9k,mac80211
snd 69141 21 snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_seq,snd_rawmidi,snd_hda_codec,snd_hda_intel,snd_seq_device,snd_seq_midi
mei_me 18421 0
mei 77692 1 mei_me
soundcore 12680 1 snd
drm 296739 2 nvidia
wmi 19070 1 acer_wmi
video 19318 1 acer_wmi
mac_hid 13205 0
lp 17759 0
parport 42299 3 lp,ppdev,parport_pc
hid_generic 12548 0
usbhid 53014 0
hid 101512 2 hid_generic,usbhid
tg3 162230 0
ahci 25819 4
libahci 31898 1 ahci
ptp 18580 1 tg3
pps_core 19027 1 ptp
比方说,ath9k就是我的无线网卡驱动,后面配置内核选项的时候要是不选,那就上不了无线了……
2.下载内核源码、解压
The Linux Kernel Archives
下载自己需要的版本源码,我的是linux-3.12-rc6.tar.xz我是直接用右键“提取到此处”
3.安装libncurses5-dev(可选)
Ubuntu没有预装,导致配置内核选项使报错
jiawen@acer:~/Dev/linux-3.12-rc6$ make menuconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1
make: *** [menuconfig] 错误 2
老老实实安装
jiawen@acer:~/Dev/linux-3.12-rc6$ sudo apt-get install libncurses5-dev
4.配置内核选项
这一步可以又很多选择,具体参看README文件,个人偏爱make menuconfig清楚、快速、最主要顺手
进入解压得到的内核源码目录
jiawen@acer:~/Dev/linux-3.12-rc6$ make menuconfig
然后在出现得伪图形界面里“做选择题”,常用键盘操作如下:
上下左右键导航
空格键修改属性(空着是不要被编译安装到内核的;M使以模块的形式编译,在需要的时候加载到内核;*是内核需要的)
/键搜索
等都选完了,保存
要说编译安装,那都不是事儿,交给电脑,让它搁那跑就行。
主要是配置,那么多选项,好些还不认识,其实向我这种菜鸟多数时候使用默认的就好
但是谁的电脑没点小特殊呢,我的无线网卡AR5B97的驱动在之前3.10版本里默认不起用,那叫一悲剧……
用/键搜索ath9k,按提示找到,然后修改属性为M
5.编译
make -j4
解释:除了安装,其他操作都是普通权限,README里也说了,不要滥用root权限;“-j4”参数理解为job*4,让make快点编译,照理说我的i5 480m是双核四线程的,给个4应该挺合理的,具体的自行GOOGLE;好像自从上了3.0以后,内核编译是连同模块一起都给办了
这一步要等,内核源码,下载下来压缩包70多兆,解压变大了一点,一编译就变成巨无霸了,东西特多,慢慢等,干点别的,出去走走
我的这配置,一边编译一边正常使用干别的,一个小时,不多不少
6.安装
sudo make modules_install install
解释:这一步要加权限;内核模块一起装
完事了,重启吧
注:之前说了,安装的Nvidia闭源驱动不会随内核一起更新,所以在更新内核以后,重新编译安装驱动,才能正常工作,这里重启以后,可能没办法进桌面。没关系,Ctrl+Alt+F1进CLI重新安装驱动就好了。
出现问题:重启后,无法正常进入CLI,回想起来好像是FB_VESA那儿有选项弄错了,导致驱动无法正常安装,超低分辨率,无奈,暂且退回3.11。前车之鉴哪,配置那儿出错了,就得重来,今天可没一个小时可耗在这上面了,洗洗睡吧,以后再说
参考解决方法:重来的时候,用/键搜索FB_VESA,找到VESA VGA graphics support修改属性为启用(*)
再就是,记得gentoo的docs里写道
For x86 and AMD64 processors, the in-kernel framebuffer driver conflicts with the binary driver provided by nVidia. If you will be compiling your kernel for these CPUs,you must completely remove support for the in-kernel driver as shown:
[Collapse]
Kernel configuration
Device Drivers --->
Graphics Support --->
<*> Support for frame buffer devices --->
< > nVidia Framebuffer Support
< > nVidia Riva support
Device Drivers --->
Graphics Support --->
<*> Support for frame buffer devices --->
< > nVidia Framebuffer Support
< > nVidia Riva support
A framebuffer alternative is uvesafb, which can be installed parallel to nvidia-drivers.
意思时说,把nVidia Framebuffer Support和nVidia Riva support都舍去注:有些网站提供的简易方法是到http://kernel.ubuntu.com/~kernel-ppa/mainline/下载别人预编译好的内核deb包,然后dpkg -i安装
建议别这么做,因为查看他们的编译选项得知FB_VESA没有被编译进内核,这就使得编译安装NVIDIA的闭源驱动不那么容易了。