核心編譯及模組相關命令使用

來源:互聯網
上載者:User

        本文講解了怎樣進行核心編譯及模組相關命令的使用方法。


一 Linux核心相關資訊

#查看Linux系統[root@serv01 ~]# unameLinux#查看所有資訊[root@serv01 ~]# uname -aLinux serv01.host.com2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40EDT 2011 x86_64 x86_64 x86_64 GNU/Linux#核心資訊[root@serv01 ~]# uname -r2.6.32-131.0.15.el6.x86_64  #/boot目錄下/boot#驅動initrd-2.6.32-131.0.15.el6.x86_64kdump.img#核心vmlinuz-2.6.32-131.0.15.el6.x86_64 #案頭版的核心存放位置[root@larrywen boot]# cd/usr/src/kernels/2.6.32-131.0.15.el6.x86_64/[root@larrywen 2.6.32-131.0.15.el6.x86_64]#lsarch  crypto   firmware  include ipc     lib       Makefile.common  Module.symvers  samples security  System.map  usrblock drivers  fs        init    kernel  Makefile  mm               net             scripts  sound    tools       virt #解壓核心到/usr/src下[root@serv01 ~]# tar -xvf linux-2.6.38.tar.gz-C /usr/src/[root@serv01 ~]# cd /usr/src/linux-2.6.38/[root@serv01 linux-2.6.38]# pwd/usr/src/linux-2.6.38 #已經安裝好的版本有設定檔[root@larrywen ule-sa2]# cd/usr/src/kernels/2.6.32-131.0.15.el6.x86_64/[root@larrywen 2.6.32-131.0.15.el6.x86_64]#ls .config.config #查看設定檔[root@serv01 linux-2.6.38]# vim/boot/config-2.6.32-131.0.15.el6.x86_64 #源碼不區分32位和64位 #查看make協助#需要在linux-2.6.38目錄下[root@serv01 linux-2.6.38]# make helpclean 清除,保留設定檔mrproper 清除,不保留設定檔,更徹底 make menuconfig:圖形介面make xconfig:圖形介面,需要安裝QT#<*>:製作成核心#<M>:製作成模組

二 編譯配置

[root@serv01 linux-2.6.38]# make menuconfig HOSTCC  scripts/basic/fixdep HOSTCC  scripts/basic/docproc HOSTCC  scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.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] Error 1make: *** [menuconfig] Error 2[root@serv01 linux-2.6.38]# yum install"ncurses-devel" -y #OCFS:Oracle Class FileSystem  #配置後產生.config檔案[root@serv01 linux-2.6.38]# ls .config[root@serv01 linux-2.6.38]# vim Makefile [root@serv01 linux-2.6.38]# lsarch/x86/boot/ -darch/x86/boot/

三 編譯

[root@serv01 linux-2.6.38]# make bzImageRoot device is (8, 2)Setup is 14908 bytes (padded to 15360bytes).System is 3704 kBCRC 7521c374Kernel: arch/x86/boot/bzImage is ready  (#1)

 

四 編譯模組

[root@serv01 linux-2.6.38]# make modules

五 安裝模組

[root@serv01 linux-2.6.38]# makemoudule_install#make moudule_install拷貝到該目錄[root@serv01 linux-2.6.38]# ls/lib/modules/2.6.32-131.0.15.el6.x86_64/kernel/ [root@serv01 linux-2.6.38]# ls/lib/modules/2.6.38/kernel#出現這個錯誤是因為交換分區過小 /bin/sh: line 1: 10010 Killed                  /sbin/depmod -ae -F System.map2.6.38make: *** [_modinst_post] Error 137

六 安裝

[root@serv01 linux-2.6.38]# make install#可以比較下已有版本和編譯的版本的不同,(編譯版本:沒選防火牆)[root@serv01 linux-2.6.38]# ls/lib/modules/2.6.38/kernel/net/802   9p   bluetooth  can  dccp          ieee802154  ipv6 llc       phonet  rfkill sctp    wimax     xfrm8021q atm  bridge     core dns_resolver  ipv4        key  mac80211  rds     sched  sunrpc  wireless[root@serv01 linux-2.6.38]# ls/lib/modules/2.6.32-131.0.15.el6.x86_64/kernel/net/802   9p   bluetooth  can  dccp        ipv4  key mac80211   phonet  rfkill sctp    wimax     xfrm8021q atm  bridge     core ieee802154  ipv6  llc netfilter  rds     sched  sunrpc  wireless [root@serv01 linux-2.6.38]# ls /lib/modules/2.6.38/kernel/fs/ntfs/ntfs.ko [root@serv01 linux-2.6.38]# ls/boot/grub/grub.conf/boot/grub/grub.conf[root@serv01 linux-2.6.38]# cat/boot/grub/grub.conf# grub.conf generated by anaconda# ## # Note that you do not have to rerun grubafter making changes to this file# # NOTICE: You have a /boot partition.  Thismeans that# #         all kernel and initrd paths are relative to /boot/, eg.# #         root (hd0,0)# #         kernel /vmlinuz-version ro root=/dev/sda2# #         initrd /initrd-[generic-]version.img# #boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle Red Hat Enterprise Linux(2.6.32-131.0.15.el6.x86_64)       root(hd0,0)             kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro             root=UUID=110fab7c-85c4-4bae-9114-98bc2ada24d8rd_NO_LUKS             rd_NO_LVM rd_NO_MD rd_NO_DMLANG=en_US.UTF-8             SYSFONT=latarcyrheb-sun16KEYBOARDTYPE=pc KEYTABLE=us             crashkernel=auto rhgb quiet                    initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img [root@serv01 linux-2.6.38]# cat/boot/grub/grub.conf#/boot目錄下新產生的檔案 initramfs-2.6.38.imgvmlinuz-2.6.38 #會在這個檔案中新加一個核心資訊[root@serv01 linux-2.6.38]# cat/boot/grub/grub.conf #出現錯誤一般是交換分區過小,我們可以增加交換分區。如何增加交換分區,請參考此文:系統營運技巧(三)——利用dd命令增加交換分區

七 模組相關命令使用

#查看當前系統載入的模組[root@serv01 linux-2.6.38]# lsmod#手工載入模組[root@serv01 linux-2.6.38]# cd/lib/modules/2.6.38[root@serv01 linux-2.6.38]# cd kernel/ns[root@serv01 linux-2.6.38]# insmod/lib/modules/2.6.38/kernel/fs/fat/fat.ko[root@serv01 linux-2.6.38]# lsmod |grep fat[root@serv01 linux-2.6.38]# insmod/lib/modules/2.6.38/kernel/fs/fat/vfat.ko[root@serv01 linux-2.6.38]# lsmod |grep fat#卸載模組,可以跟模組名,也可以跟全路徑[root@serv01 linux-2.6.38]# rmmod fatERROR:Module fat is in use by vfat[root@serv01 linux-2.6.38]# rmmod vfat[root@serv01 linux-2.6.38]# lsmod |grep fat#模組之間有依賴,先加這個不能加上[root@serv01 linux-2.6.38]# insmod/lib/modules/2.6.38/kernel/fs/fat/vfat.ko #自動處理依賴關係,不需要加全路徑[root@serv01 linux-2.6.38]# modprobe vfat[root@serv01 linux-2.6.38]# lsmod |grep fat #-r參數,表示remove[root@serv01 linux-2.6.38]# modprobe -r fat[root@serv01 linux-2.6.38]# modprobe -rvfat #記錄模組依賴[root@serv01 linux-2.6.38]# vim/lib/modules/2.6.32-131.0.15.el6.x86_64/modules.dep [root@larrywen pdf]# pwd/opt/soft/ule-sa2/pdf[root@larrywen pdf]# ls ule-kerenl.pdfule-kerenl.pdf[root@larrywen pdf]# ls ule-module.pdfule-module.pdf #查看模組資訊[root@serv01 linux-2.6.38]# modinfo vfatfilename:      /lib/modules/2.6.32-131.0.15.el6.x86_64/kernel/fs/fat/vfat.koauthor:         Gordon Chaffeedescription:    VFAT filesystem supportlicense:        GPLsrcversion:     ACCC2F7E9526F402F526976depends:        fatvermagic:       2.6.32-131.0.15.el6.x86_64 SMPmod_unload modversions

  我的郵箱:wgbno27@163.com  新浪微博:@Wentasy27           公眾平台:JustOracle(號:justoracle)  資料庫技術交流群:336882565(加群時驗證 From CSDN XXX)  Oracle交流討論群組:https://groups.google.com/d/forum/justoracle  By Larry Wen
 
@Wentasy 博文僅供參考,歡迎大家來訪。如有錯誤之處,希望批評指正。原創博文如需轉載請註明出處,謝謝 [CSDN部落格]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.