當最初開始LDD編程時,經常會碰到這種情況,下載編譯的核心原始碼和當前正在啟動並執行核心不一樣。
第一階段
有時候你下載的核心版本相對正確,但卻仍然不能insert成功,這有另一方面的東西要check:
1. gcc的版本,比較:
cat /proc/version和gcc -v
2. 核心config的比較,在關鍵的選項上不能相左
當前核心config:
/lib/modules/`uname -r`/build/.config
比如,在大記憶體機器上可能要開啟PAE:CONFIG_X86_PAE=y
2.6.32-28-generic-pae #55-Ubuntu SMP Mon Jan 10 22:34:08
而預設的核心原始碼是不會開啟的,所以insert失敗
PAE依賴於CONFIG_HIGHMEM64G=y
,否則PAE選項是看不到的:
High Memory Support (64GB) ---> │ │
-*- PAE (Physical Address Extension) Support
同時可以把version signature設成一樣:
CONFIG_VERSION_SIGNATURE="Ubuntu 2.6.32-28.55-generic-pae 2.6.32.27+drm33.12"
當運行核心中有檢查的時候
CONFIG_CHECK_SIGNATURE=y
dkms需要裝:
$ aptitude show dkms
Package: dkms
State: not installed
Version: 2.1.1.2-2ubuntu1
Priority: optional
Section: admin
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Uncompressed Size: 475k
Depends: module-init-tools, gcc, make | build-essential | dpkg-dev, patch
Recommends: fakeroot, lsb-release, menu | sudo, linux-headers-2.6-686 | linux-headers-2.6-amd64 |
linux-headers-generic | linux-headers, linux-image
Description: Dynamic Kernel Module Support Framework
DKMS is a framework designed to allow individual kernel modules to be upgraded without changing the
whole kernel. It is also very easy to rebuild modules as you upgrade kernels.
Homepage: http://linux.dell.com/dkms
第二階段
基本配置正確後,接下來是version和magic不匹配的問題:
[12151.939695] h: no symbol version for module_layout
[13544.669533] h: disagrees about version of symbol module_layout
以後一種更常見。
CONFIG_VERSION_SIGNATURE的設定絲毫不起作用,使用modinfo查看系統ko和自編ko:
$ sudo modinfo h.ko
filename: h.ko
license: Dual BSD/GPL
depends:
vermagic: 2.6.32.41+drm33.18 SMP mod_unload modversions 686
系統ko
vermagic: 2.6.32-28-generic-pae SMP mod_unload modversions 586TSC
parm: debug:Debug level (0=none,...,16=all) (int)
parm: eeprom_bad_csum_allow:Allow bad eeprom checksums (int)
parm: use_io:Force use of i/o access mode (int)
其定義在Makefile檔案中,
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 32
EXTRAVERSION = .41+drm33.18
NAME = Man-Eating Seals of Antiquity
需要將EXTRAVERSION替換:-28-generic-pae
modversions是通過enable該選項編譯核心出來的:CONFIG_MODVERSIONS=y
而586TSC則是ARCH,是通過設定CONFIG_M586TSC(Pentium-Classic)出來的,而現在編譯的核心是686(Pentium-Pro)。
所以解決辦法:
1. 編輯Makefile檔案使前面基本的版本號碼一樣
2. enable CONFIG_MODVERSIONS
3. 選擇同樣的cpu類型
第三階段
做完了這一切以後,還是不能插入:disagrees about version of symbol module_layout
這種情況是有可能的,不僅僅是大小版本的差異,而且你不能保證你的:
This indicates you have compiled the module against a different version
of the kernel than is running. Note that even if the running kernel and
kernel source have the same numerical value (e.g. both are
2.6.31-20-server), if the two use different configuration options, you
may see this error. Also check if there are multiple versions of this
module on the machine and ensure you are loading the correct one.
只能採取終極辦法了,自己從source裡編一個,即:
apt-get install linux-source-2.6.32
cp /lib/modules/`uname -r`/build/.config .config Or:
cp /boot/config-`uname -r` .config
make -j4
sudo make install
make modules
sudo make modules_install
$ cd /boot && sudo mkinitramfs -k -o initrd.img-2.6.32.41+drm33.18-pae 2.6.32.41+drm33.18-pae
Working files in /tmp/mkinitramfs_4KnPce and overlay in /tmp/mkinitramfs-OL_XRVNGw
/tmp/mkinitramfs_4KnPce$ ls
bin conf etc init lib sbin scripts
編輯grub.cfg加入新編譯的核心
-EOF