学院首页>操作系统>Linux>开源空间:自己做个迷你型linux内核

开源空间:自己做个迷你型linux内核

作者:cexoyq 来源:chinaunix 添加时间:2006-5-26 14:02:04

hda1----新装的RH9

hdc1----64M的硬盘,生成的小型linux就装在这个盘上,还未分区格式化。

环境:ms的虚拟机5.1版。

先重新编译内核,把不需要的全部去掉,这样模块也只有几M了。编译后生成了

内核:vmlinuz-2.4.20-8custom

initrd:initrd-2.4.20-8custom.img(这个没用到,在GRUB中使用它反而不能启动了,提示要加init内核参数。)

可加载模块:/lib/modules/2.4.20-8custom

fdisk /dev/hdc 分区,并激活,保存后退出。

mkext2fs /dev/hdc1

mkdir /mnt/hd2

mount /dev/hdc1 /mnt/hd2

mkdir /mnt/hd2/boot/grub -p

cp /boot/vmlinuz.2.4.20-8custom /mnt/hd2/boot/ -a

cp /boot/initrd.2.4.20-8custom /mnt/hd2/boot/ -a

cp /boot/grub/stage? /mnt/hd2/boot/grub/ -a

cp /boot/grub/grub.conf /mnt/hd2/boot/grub/ -a

cp /boot/grub/e2fs_stage1_5 /mnt/hd2/boot/grub/ -a

然后运行:grub

root (hdc1,0)

setup (hdc)

quit

这样,小硬盘就能启动了(不过进不了系统,内核启动完后就死了)。但是记得要配置一下grub.conf,改成:

default=1

timeout=10

title linux

root (hd0,0)

kernel /boot/vmlinuz-2.4.20-8custom ro root=/dev/hda1

不能够加入initrd,要不然会出错的,不清楚原因。有谁知道的可以告诉我吗?[email]cexoyq1020@163.com[/email],谢谢了。

制作文件系统

建立目录:/home,/mnt,/proc,/lib,/sbin,/bin,/root,/etc,/dev

需要的文件:/dev

/dev/console

系统控制台设备,非常重要。

/dev/fd0

站内搜索