作者 主題: Lpi 102 Task Oriented Topic 105:Kernel  (閱讀 4321 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
Lpi 102 Task Oriented Topic 105:Kernel
« 於: 2004-09-20 16:08 »
1.105.1 Manage/Query kernel and kernel modules at runtime

***manage and/or query a kernel and kernel loadable modules
***get information about the currently running kernel

/proc #the interface between kernel and user
less /proc/sys/net/ipv4/ip_forward * #query kernel ???
echo 1 > /proc/sys/net/ipv4/ip_forward  #manaage kernel

***get information about the currently running kernel modules
lsmod

***manually loading and unloading modules as appropriate

modprobe -r --remove #remove
/sbin/modprobe -a -t /lib/modules/2.2.10/ipv4/ip_masq* #--all

/sbin/modprobe /lib/modules/2.2.10/ipv4/ip_masq_ftp #/*加载ip伪装的ftp模块*/
insmod /lib/modules/2.2.17-4CLE/ipv4/ip_masq_ftp.o

/sbin/modprobe /lib/modules/2.2.10/ipv4/ip_masq_irc #/*加载ip伪装的irc模块*/

/sbin/modprobe /lib/modules/2.2.10/ipv4/ip_masq_raudio
/sbin/modprobe /lib/modules/2.2.10/ipv4/ip_masq_user
/sbin/modprobe /lib/modules/2.2.10/ipv4/ip_masq_autofw
/sbin/modprobe -a -t /lib/modules/2.2.10/ipv4/ip_masq*

/*自动加载ip伪装的相关模块*/
modprobe usb-uhci
modprobe -lt net | grep sun
modprobe -t net
modprobe 3c59x
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp



http://www.linuxfans.org/nuke/modules.php?name=News&file=article&sid=2299
???
insmod

***determine when modules can be unloaded ???

***what parameters a module accepts
modinfo


***configure the system to load modules by names other than their file name ???

vi /etc/modules.conf
代碼: [選擇]

alias eth0 = 3c509
options eth0 io=0x300 irq=2


***depmod
***modules.dep #modprobe check from modeules.dep

depmod -a 2.4.20-8test01 對/lib/modules/2.4.20-8test01/裡所有*.o的modules做相依性的檢查,來產生/lib/modules/2.4.20-8test01/modules.dep檔案

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
1.105.2 Reconfigure, build, and install a custom kernel and kernel modules

***customizing the current kernel configuration
vi Makefile
make <oldconfig|menuconfig|xconfig|config>

***building a new kernel,
make mrproper
make bzImage 1>/dev/null

***building kernel modules as appropriate
make modules 1>/dev/null

***installing the new kernel as well as any modules
head -5 Makefile
kv=2.6.5-1.358custom
cp /usr/src/linux-2.4.20-8/arch/i386/boot/bzImage /boot/vmlinuz-$kv
cp System.map /boot/System-map-$kv

make modules_install #install modules

mkinitrd -f /boot/initrd-$kv.img $kv


***ensuring that the boot manager can locate the new kernel
--in Lilo:
代碼: [選擇]

image=/boot/vmlinuz-2.6.5-1.358custom
 label=linuxWithntfs
        initrd=/boot/initrd-2.6.5-1.358custom.img
        read-only
        append="rhgb quiet root=LABEL=/"


means the root partition is in /dev/hda3
and image can be found from /boot/bzImage-xxxxx

--in Grub: kernel /bzImage-2.4.18-40test01 ro root=/dev/hda3 mem=128M init=/bin/bash
代碼: [選擇]

title Fedora Core (2.6.5-1.358)
        root (hd0,4)
        kernel /vmlinuz-2.6.5-1.358 ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.5-1.358.img
root (hd0,4) means /boot fs is in /dev/hda5
       kernel xxx ro root=LABEL=/

#df /
/dev/hda3
#e2label /dev/hda3
/

figure out the / fs is in /dev/hda3


***associated files (generally located under /boot

cp /usr/src/linux-2.4.20-8/arch/i386/boot/bzImage /boot/vmlinuz-$kv
cp System.map /boot/System-map-$kv
mkinitrd -f /boot/initrd-$kv.img $kv

vmlinuz-$kv
System-map-$kv
initrd-$kv.img


make config ???
make install ???