|
|
|
|
|
|
由 feiiiiiii 于 星期三, 05/19/2010 - 13:36 发表
|
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 第一个软驱 /dev/hda /dev/hda[1-8] IDE 硬盘及分区 /dev/initctl 实际上是一个 FIFO 设备,跟 init 有关(切换运行级别时用于新 init 与原 init 通信) /dev/initrd Initial RAM disk /dev/input (目录)Input core(包括游戏杆、鼠标等) /dev/kmem 内核虚拟内存 /dev/loop[0-7] Loopback 设备 /dev/mem 访问物理内存 /dev/null NULL 设备 /dev/psaux PS/2 鼠标 /dev/ptmx UNIX98 PTY master /dev/pts (目录)UNIX98 PTY slaves /dev/ptyp[0-7] 伪终端主设备(远程登录使用) /dev/ram[0-7] /dev/ramdisk /dev/ram RAM Disk 设备。至少/dev/ram0 是应用 initrd 机制所必须的。 /dev/ramdisk 链接到/dev/ram0,是为了兼容老版本内核而保留的。 /dev/ram 链接到/dev/ram1。 /dev/random 随机数发生器 /dev/sda /dev/sda[1-8] SCSI 磁盘及分区设备 /dev/shm 共享内存设备 /dev/systty 指向系统 tty 设备的符号链接,一般是 tty0。 /dev/tty 当前 TTY 设备 /dev/tty[0-7] 虚控制台(Virtual console) /dev/ttyp[0-7] 伪终端从设备 /dev/ttyS0 /dev/ttyS1 串口(COM1 和 COM2) /dev/urandom 速度更快、安全性较差的随机数发生器 /dev/zero 零设备,只能读 0 出来 需要的文件:/etc etc/default (目录)某个命令(比如 useradd)的缺省设置(man useradd(8)) /etc/ld.so.cache 由 ldconfig 命令根据/etc/ld.so.conf 文件产生 /etc/ld.so.conf 库文件路径配置文件,ldconfig 命令根据该配置文件生成/etc/ld.so.cache /etc/localtime 本地时间、时区设置 /etc/login.defs 全局缺省设置 /etc/fstab 文件系统列表(man fstab(5)) /etc/group 组文件(man group(5)) /etc/hosts 列出主机名和 IP 地址(man hosts(5)) /etc/init.d 符号链接到/etc/rc.d/init.d /etc/initlog.conf Initlog 日志配置文件(man initlog(8)) /etc/inittab Init 配置文件(man inittab(5)) /etc/ioctl.save 该文件包含了用于单用户模式的串口和终端参数,因为这些参数是由 getty 设置的, 而在单用户模式时没有运行 getty,所以用该文件保存参数。单用户模式对系统安全 是个威胁,我们应该禁止使用单用户模式,因此这个文件实际上并没有必要复制过 来。 /etc/issue 登录信息和标识文件(man issue(5)) /etc/modules.conf 模块的配置文件(man modules.conf(5)) /etc/mtab 已经挂载的文件系统列表(man mount(8)) /etc/nsswitch.conf Name Service Switch 的配置文件(配置名称服务数据源和查询的顺序)(man nss witch.conf(5)) /etc/pam.d 放置 PAM 配置文件的目录(有关 PAM 请参考 5.5 节) /etc/passwd 用户口令文件(man passwd(5)) /etc/profile 系统环境变量和登录配置文件 /etc/rc.d 放置启动脚本的目录 /etc/services 列出可用的网络服务及其端口(man services(5)) /etc/termcap 终端(terminal)功能数据库(man termcap(5)) 另外,跟网络参数有关的文件也要一一拷贝过来。要不然就得手动配置网络参数了。 需要的文件:/lib 用“ldd 命令名称” 来取得命令所需要的LIB库,然后拷贝过来(要建立相应的目录)。 /bin 和/sbin:根据自己的需要拷贝相应的文件。我把 iptables,tc 等拷贝过去。 需要的文件:/lib/modules 整个拷贝重新编译内核后的整个"2.4.20-8custom"目录,因为经过了裁剪,所以我的只 有 5M,不大可以完全使用。这个很重要,网络的驱动, iptables,tc 等都靠它了。 下载 busybox 并编译安装。http://www.busybox.net/downloads 下载最新版的 busybox-1.1.2.tar.bz2 到/root 解压后进入 busybox-1.1.2 make menuconfig -----选自己需要的命令,也可以从源 RH9 中拷贝,不过那样就要拷 LIB,麻烦。记得要选静态编译,还有 init. make makeinstall 完成后在目录下生成“_install”目录,把所有目录及文件拷贝到小硬盘中。 重新配置/etc/inittab,/etc/fstab,/etc/rc.d/rc.sysinit /etc/inittab ::sysinit:/etc/rc.d/rc.sysinit ::askfirst:-/bin/sh tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh tty4::askfirst:-/bin/sh ::restart:/sbin/init ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -a /etc/fstab proc /proc proc defaults 0 0 /etc/rc.d/rc.sysinit #!/bin/sh mount -a 添加自己的启动脚本。 然后关机,在虚拟机中把小硬盘设置成第一个硬盘,也就是(hd0,0) 就可以看到你的 mini-linux 在跑了。 问题: 做出来的系统每次启动后,网卡驱动是加载了(因为我编译在内核中),但是用 "ifconfig eth0"却看不到它的配置信息,可能是未配置, 而所有的配置文件/etc/都已经拷贝了。只能用"ifconfig eth0 10.0.0.103"配置一下 才能使用网络。 在 grub 中不能使用 initrd 参数。出错提示要加 init 内核参数,而加了 init 参数也 不行。去掉 initrd 就可以启动了。很是奇怪。
|
|
|
|
|
|
|