FloppyLinux制作过程

       在虚拟机中虚拟一张1.44M的软盘,就可以制作自己的Linux操作系统了,通过本教程可以对Linux的开机启动过程,根文件系统的制作,内核编译有更深层次的理解,当然也可以在本教程的基础上进行扩展,制作更加完善的Linux操作系统。

实验条件:

Redhat9.0(2.4.20-8)
busybox-1.00.tar.gz  linux-2.4.20.bz2


软盘上安装引导器(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 
其中可执行文件busybox在bin目录下,其他的都是指向他的符号链接. 




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/init.d/rcS,
/etc/fstab
/etc/inittab
/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 0 
  default 10
  title  FloppyLinux   root (fd0)  kernel /boot/bzImage  initrd /initrd.img.gz
  
 4 制作Ramdisk的镜像文件:
 # dd if=/dev/zero of=/dev/ram1
dd: 正在写入 ‘/dev/ram1’: 设备上没有空间 
读入了 8193+0 个块 
输出了 8192+0 个块 
 #mke2fs  -m0  /dev/ram1
 #mkdir /mnt/ram 
 #mount /dev/ram1 /mnt/ram
将先前做好的floppylinux根文件系统拷贝到ram1上. 
 #cp -R /tmp/floppy-linux /*  /mnt/ram
 #umount /dev/ram1
 # dd if=/dev/ram1 of=/tmp/floppy-linux /initrd.img
 # file initrd.img 
 initrd.img: Linux rev 1.0 ext2 filesystem data
 用loop设备来把他重新挂装到文件系统里:
 # mount -o loop initrd.img /mnt/ram/
 查看/mnt/ram下的内容,和/tmp/floppy-linux /下的一模一样
 # ls /mnt/ram
 bin dev etc lost+found mnt proc sbin tmp var
 #umount /mnt/ram
 压缩initrd.img印象文件
 # gzip -v9 initrd.img
initrd.img: 90.1% -- replaced with initrd.img.gz 
查看压缩后的大小: 
 # ls -lh initrd.img.gz
 只有406K
 
 5编译linux系统内核
 #cp linux-2.4.20.bz2 /usr/src/ 
 #cd /usr/src
 #tar xfvj linux-2.4.20.bz2
 #ln -s linux-2.4.20 linux 
 进入linux源代码目录: 
 #cd linux
 清理源代码树: 
 #make mrproper 
 运行配置程序: 
 #make menuconfig
 
 
code maturity level options 
先选择N,当我们配置好常规的东西,要加入framebuffer支持时再将这一项选择Y,如果不在code maturity level options选择为Y,将不能配置framebuffer. 
Loadable module support 
选择N,为了简化系统的制作,我在这个项目中不选择可加载内核模块的支持. 
processor type and features 
processor family 中选择386CPU 
其他选项都选择N.
General setup 
networking support 选择Y 
PCI support 选择Y 
System V ipc 选择Y 
systrl support选择Y 
kernel support for ELF 选择Y 
其余内容都可以选择N, 
chnology devices (MTD) 
Parallel port support 
Plug and Play configuration 
以上三个大项中的所有内容选择N 
block devices 
Normal floppy disk support 
Loopback device support 
RAM disk support 
initial RAM disk (initrd) support 
Per partition statics in /proc/partitions 
以上几项选择Y,其余全部选择N. 
Multi-device support (RAID and LVM) 
Cryptography support (CryptoAPI) 
 这两个大项全部选择N
Networking options 
这一大项中,只需要把下列项目编译进内核: 
Packet socket :mmapped IO 
 TCP/IP networking
Telephony Support 选择N 
ATA/IDE/MFM/RLL support 
选择Y,然后下面的'IDE,ATA and ATAPI Block Devices'按钮就被激活 
下面几项选择Y,其余都可以是N. 
Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support 
Include IDE/ATA-2 DISK support 
Auto-Geometry Resizing support 
Include IDE/ATA CDROM support


SCSI support 
Fusion MPT device support 
IEEE 1394(FireWire) support 
I2O device support 
 全部选择N
Network device support 
 选择Y
 然后点Ethernet(10 or 100 Mbit)按钮选择网卡驱动(Reltek8139)
Amateur Radio support 
IrDA (infrared) support 
ISDN subsystem 
Old CD-ROM drivers (not SCSI,not IDE) 
Input core support 
 全部选择N
 Charcter devices
 除了Virtual terminal和Support for console on terminal两项,其他全选N
Multimedia devices 
Crypto Hardware support 
 全部选择N.
 File sytems
选择其中有三个: 
/proc file system support. 
Second extended fs support BabyLinux的基本文件系统. 
ISO 9660 CDROM filesytem support用光盘. 
Console drivers
.前面三个全部选择Y, 
Frame-buffer support按钮是灰色的不能选,别急,回到第一个大选项: 
Code maturity level options 选择Y,就可以激活这个按钮了. 
下面几个选项需要选择Y: 
Support for framebuffer devices 
VESA VGA graphics console
Support only 8 pixels wide fonts 
剩下的几个大项全部选N
 保存后退出,配置程序会自动生成一个隐藏的配置文件.config
 
#make dep 
#make bzImage
bzImage为654K




6 整合启动盘
#cp  bzImage /mnt/floppy/boot
#cp  /tmp/floppy-linux/initrd.img.gz  /mnt/floppy
全部文件(文件夹)如下:


/lost+found/
/boot/
/boot/grub/
/boot/grub/stage1
/boot/grub/stage2
/boot/grub/menu.lst
/boot/grub/grub.conf
/boot/bzImage
/initrd.gz




7 测试
重启机器,从软盘启动
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值