热门关键字:  ubuntu  分区  函数  linux系统进程  Fedora

自制一小型的linux系统mylinux

来源: 作者: 时间:2007-07-09 Tag: 点击:

通过grub引导程序引导编译后的内核文件bzImage,把制作的文件系统变成ramdisk镜像文件,通过内存加载镜像文件完成文件系统的注入;其中的命令通过编译busybox生成bin,sbin文件;注意:

内核文件+文件系统镜像文件+grub引导程序<=1440K

详细步骤

1. 软盘上安装引导器(grub

具体操作如下:

# mke2fs /dev/fd0

创建了 ext2 文件

# mount /dev/fd0 /mnt/floppy

现在,创建一些目录,并将一些关键文件复制到软盘:

# mkdir /mnt/floppy/boot

# mkdir /mnt/floppy/boot/grub

# cp /boot/grub/stage1 /mnt/floppy/boot/grub

# cp /boot/grub/stage2 /mnt/floppy/boot/grub

 

 

运行grub命令

grub> 提示符处,输入:

grub> root (fd0)

grub> setup (fd0)

grub> quit

引导盘完成。

 

 

2 配置busybox

新建一个目录存放资料:

#mkdir /floppylinux

make menuconfig配置busybox

#cp busybox-1.00.tar.gz /floppylinux

#cd /floppylinux

#tar xvfz busybox-1.00.tar.gz

#cd busybox-1.00

#make menuconfig

下面是需要编译进busybox的功能选项,

 

General Configuration应该选的选项

Show verbose applet usage messages

Runtime SUID/SGID configuration via /etc/busybox.conf

Build Options

Build BusyBox as a static binary (no shared libs)

Installation Options

Don't use /usr

其他选项都是一些linux基本命令选项默认

配置好后退出并保存.

 

编译并安装busybox

 

#make

#make install

编译好后在busybox目录下生成子目录_install,里面的内容:

drwxr-xr-x 2 root root 4096 11 24 15:28 bin

lrwxrwxrwx 1 root root 11 11 24 15:28 linuxrc -> bin/busybox

drwxr-xr-x 2 root root 4096 11 24 15:28 sbin

其中可执行文件busyboxbin目录下,其他的都是指向他的符号链接.

 

 

3 制作根文件系统

建立临时目录,该目录为软盘的文件系统

#mkdir //tmp/floppy-linux

busybox下的_install目录下的文件复制过来:

#cp ./_install /tmp/floppy-linux –r

 

#cd /tmp/floppy-linux

# mkdir dev etc etc/init.d proc mnt tmp var

# chmod 755 dev etc etc/init.d bin mnt tmp var

# chmod 555 proc

# cd dev

# mknod tty c 5 0

# mknod console c 5 1

# chmod 666 tty console

# mknod tty0 c 4 0

# chmod 666 tty0

# mknod ram0 b 1 0

# chmod 600 ram0

# mknod fd0 b 2 0

# chmod 600 fd0

# mknod null c 1 3

# chmod 666 null

 

建启动配置文件:

/etc/inittab,

/etc/init.d/rcS,

/etc/fstab

/boot/grub.conf

/boot/menu.lst

其中

#ln –s grub.conf menu.lst

initab:

::sysinit:/etc/init.d/rcS

::askfirst:/bin/sh

 

rcS:

#!/bin/sh

mount –a

# chmod 755 rc.sysinit

 

fstab:

proc /proc proc defaults 0 0

 

grub.conf:

timeout 10

default 0

title FloppyLinux   root (fd0)  kernel /boot/bzImage  initrd /initrd.img.gz

上一篇:没有了
下一篇:没有了
最新评论共有 4 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册