ºìÁªLinuxÃÅ»§
Linux°ïÖú

дÇý¶¯£­Ubuntu7.10±àÒëÄÚºË2.6.24

·¢²¼Ê±¼ä:2008-08-23 21:42:04À´Ô´:ºìÁª×÷Õß:yardslong
°²×°Íê³ÉUbuntu 7.10ºóÖ´ÐÐ ¡°uname -r¡± ÏÔʾµÄ°æ±¾ÊÇ Linux-headers-2.6.22-14-generic¡£ Óà "ls -l" ²é¿´ /usr/src/ÏÔʾµÄÓÐÁ½¸öÎļþĿ¼£ºLinux-headers-2.6.22-14-genericºÍLinux-headers-2.6.22-14¡£ÓÃUbuntuµÄÔ´¸üкÍÅäÖã¨ÎÒÓõÄÊÇÉϽ»ºÍÅ·ÖÞ¹Ù·½µÄÔ´£¬µ±È»»¹ÓÐÖÐÎĵĹٷ½Ô´£©ÒÔºóÄں˻áÉý¼¶µ½Linux-headers-2.6.22-15-generic¡£/usr/src/Ï»áÔö¼ÓÁ½¸öÎļþĿ¼£ºLinux-headers-2.6.22-15-generic ºÍLinux-headers-2.6.22-15¡£

Õâ¸öʱºòд°´ÕÕ¡¶LinuxÉ豸Çý¶¯³ÌÐò£¨µÚÈý°æ£©¡·Ð´HelloÇý¶¯ÔõôҲ±àÒë²»¹ýÈ¥£¬ÐèÒª½¨Á¢ÄÚºËÊ÷¡£Æäʵ2.4°æ±¾ºÍ2.6°æ±¾ÏÂÇý¶¯µÄ±àÒëÃüÁMakefileÎļþ£©ÊDz»Í¬µÄ£¬Éú³ÉµÄÇý¶¯Îļþºó׺ÃûÒ²²»Ò»Ñù£¬2.4Ϊ .o £¬2.6Ϊ .ko¡£¸É´à±àÒëÄÚºËʹÓñȽϸßÒ»µãµÄÎȶ¨µÄ°æ±¾£¬Ñ¡ÔñÁË2.6.24°æ±¾µÄÄںˡ£

1. °²×°×¼±¸£º

°üÓУºlibncurses5-dev£¨menuconfigÐèÒªµÄ£©ºÍessential
sudo apt-get install build-essential bin86 kernel-package
sudo apt-get install libqt3-headers libqt3-mt-dev
sudo apt-get install make
sudo apt-get install gcc

µ½ÐÂÁ¢µÃÀï°ÑËùÓÐÒÔncurses¿ªÍ·µÄÈí¼þ°üÈ«²¿×°ÉÏ¡£ÁíÍ⣬²é¿´ÏµÍ³ÊÇ·ñÓÐÕâÑùµÄÁ½¸öÃüÁÓÃtab¼ü

mkinitramfs mkisofs

2. ÏÂÔØlinux-2.6.24ÄÚºË

µ½www.kernel.org ÉÏÏÂÔØlinux-2.6.24.tar.bz2µÄÄں˷ŵ½ /usr/src/¡£

sudo -s -Hµ½³¬¼¶Óû§Ä£Ê½¡£

cd /usr/src½øÈëĿ¼¡£

tar jxvf linux-2.6.24.tar.bz2½âѹÎļþ¡£

cd /usr/src/linux-2.6.24

3. ÅäÖÃÄÚºË

ÏÈÔËÐÐÒÔÏÂÃüÁ¸´ÖƵ±Ç°Äں˵ÄÅäÖÃÎļþ¡£
cp /boot/config-`Linux-headers-2.6.22-15-generic` ./.config

sudo make menuconfig

Ñ¡Ôñ "Load an Alternate Configuration File"£¬ÔÙÑ¡ÔñÄã¸Õ²Å¿½±´¹ýÀ´µÄ.configÎļþ×÷ΪÅäÖÃÎļþ¡£È»ºóÈ·¶¨¡£µ±½áÊøºó£¬ÄãÑ¡ÔñÍ˳öʱ£¬»áÌáʾÎÊÄã "Do you wish to save your new kernel configuration?"Ñ¡Ôñyes¼´¿É¡£

4. ¿ªÊ¼±àÒë
ÕⲿµÄʱºò³öÏÖÁË¿Õ¼äµÄÎÊÌ⣬±àÒ뽫»á²úÉú1.8GµÄ¿Õ¼äÔÚ /usr/srcÏ£¬¸´ÖƵ½/lib/modulesÏÂϵÄÄÚºËÄ£¿éÒ²ÓÐ500M¡£¿Õ¼äÒ»¶¨Òª¹»£¡

make
make bzImage //±àÒëÄںˣ¬½«±£´æµ½/usr/src/linux-2.6.24.4/arch/i386/boot/ÏÂ
make modules //±àÒëÄ£¿é
make modules_install //°²×°Ä£¿é

Õâ¸öʱºòÄÚºËÊ÷ÒѾ­½¨Á¢£¬±àдhelloÇý¶¯³ÌÐò³É¹¦¡£

//hello.c
#include
#include
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");
}
module_init(hello_init);
module_exit(hello_exit);

//Makefile Îļþ
obj-m := hello.o
KERNELDIR := /lib/modules/2.6.24/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

Èç¹ûÒÔÉÏÄ㶼Íê³ÉÁËÔÚ make ʱ³öÏÖ´íÎó£¬Makefile¸ñʽ´íÎ󣬽â¾ö°ì·¨¾ÍÊÇ Äã°ÑÈç $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install Òƶ¯µ½ÐÐÊ× È»ºó°´Tab ¼ü×Ô¶¯¶ÔÆ룬ȻºóÔÚ make ¡£MakefileÒ»°ã³öÏÖTabºÍ¿Õ¸ñµÄÎÊÌ⣬ÓÃTab¼ü·Ö¸î¡£

Èç¹ûÄã²»ÏëʹÓÃеÄÄںˣ¬ÓÃËüÀ´×÷±àÒëÂß¼­Ò²¿ÉÒÔ£¬Ê¹ÓÃеÄÄں˾͵ñàÒëÍê³É£¬°üÀ¨¼ÓÔص½grubÀïÃæ¡£

5. ±àÒëÍê³É

sudo mkinitramfs -o /boot/initrd-2.6.24.img 2.6.24

´Ëʱ¿ÉÄÜÌáʾÕÒ²»µ½ÕâÑùµÄÒ»¸öÎļþ¼Ð¡°/lib/firmware/2.6.24¡±£¬ÄãÐèÒªÊÖ¹¤´´½¨Ò»¸öÕâÑùµÄÎļþ¼Ð¡£

mkdir /lib/firmware/2.6.24

make install //°²×°Äں˰²×°Íêºó/bootϽ«Ôö¼ÓÒÔϼ¸¸öÎļþ£¨ÓÃls -l *24*²é¿´£©

-rw-r--r-- 1 root root 85203 2008- 22:24 config-2.6.24

-rw-r--r-- 1 root root 37968871 2008- 08:31 initrd-2.6.24.img
-rw-r--r-- 1 root root 4014080 2008- 22:24 initrd.img-2.6.24

-rw-r--r-- 1 root root 932315 2008- 22:24 System.map-2.6.24

-rw-r--r-- 1 root root 1858864 2008- 22:24 vmlinuz-2.6.24
¸ø/boot/grub/menu.lstÖÐÌí¼ÓÒ»¸öеÄÆô¶¯ÏÈçÎÒµÄmenu.lstÔö¼ÓÁËÈçÏÂÒ»¶ÎÎÄ×Ö

title Ubuntu, kernel 2.6.24

root (hd0,0)
kernel /boot/vmlinuz-2.6.24 root=UUID=d7e2cf74-ebf5-4c78-ac2c-9f85a9809eae ro
initrd /boot/initrd-2.6.24.img

´ÓÐÂÆô¶¯¾Í¿ÉÒÔÓÃеÄÄÚºËÁË¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. wangyu ÓÚ 2008-08-23 22:26:43·¢±í:

    Ôø¾­Éý¼¶¹ýÒ»´Î£¬Ê§°Ü