打造小型Linux操作系统.doc_第1页
打造小型Linux操作系统.doc_第2页
打造小型Linux操作系统.doc_第3页
打造小型Linux操作系统.doc_第4页
打造小型Linux操作系统.doc_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一、 对linux内核进行配置和编译1. 下载linux-内核至/usr/src2. 解压并make menuconfig; make; make modules_install install 3. 得到一个bzImage文件,备份,后面要用 (bzImage所在位置:/usr/src/linux-/arch/i386/boot)二、 编译busybox1. 下载busybox(存放的位置没有太大关系)2. 对busybox进行配置#tar xvfz busybox-1.7.2.tar.gz / 解开busybox #cd busybox-1.7.2 #make menuconfig /配置busybox 下面是必需要编译进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) 原因:这个选项的作用是把busybox编译成静态链接的可执行文件,运行时才能独立于其它函数库,否则需要其它库文件才能运行Installation Options Dont use /usr 原因:这个选项也一定要选,否则make install 后busybox将安装在原系统的/usr下,这将覆盖掉系统原有的命令。选择这个选项后,make install后会在busybox目录下生成一个叫_install的目录,里面有busybox和指向他的链接。其它选项为默认选项。配置好后退出并保存. #make /编译busybox #make install /安装busybox 编译好后在busybox目录下生成子目录_install,里面的内容是:drwxr-xr-x 2 root root 4096 Nov 30 09:04 binlrwxrwxrwx 1 root root 11 Nov 30 09:04 linuxrc - bin/busyboxdrwxr-xr-x 2 root root 4096 Nov 30 09:04 sbindrwxr-xr-x 4 root root 4096 Nov 30 08:55 usr三、 制作文件系统1. 建一个目录rootfs 用来装文件系统 (在/ 目录下)2. #mkdir etc usr var tmp proc home root dev /建立文件目录 注:其中etc,proc和dev是一定要建的,bin和sbin可以拷贝busybox生成的,其他的可以象征性的建几个就可以了.3. 拷贝busybox下的_install文件夹到rootfs下 #cp -R /busybox-1.7.2/_install/* /rootfs/ 4. 在dev文件夹下建立设备文件名:#vi /rootfs/dev 其配置文件直接从原系统的/dev目录下拷贝过来。(一定要带-r参数)#cp r /dev/* /rootfd/dev 5. 建立etc目录下的配置文件 busybox.conf group inittab motd passwd resolv.conf shadow- fstab init.d issue mtab profile shadow 其中init.d是一个目录,从busybox-1.7.2源代码目录下拷贝过来. #cp -R busybox-1.7.2/examples/bootfloppy/etc/init.d /rootfs/etc/ 把init.d拷过来后要更改其中的文件rcS: 确保这个文件是可执行的,否则请改成可执行的: #chmod u+x rcS rcS的内容是: #! /bin/shmount -o remount,rw /bin/mount -a/etc/mtabechoechoechoechoecho -en ttWelcom to Zml Linux0330;39mnhostname ZmlLinuxbusybox.conf是一个空文件其他文件的内容如下:fstab/dev/fd0 / ext2 defaults 0 0none /proc proc defaults 0 0/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0grouproot:0:rootinittab:sysinit:/etc/init.d/rcS:askfirst:/bin/shtty2:respawn:/bin/getty 38400 tty2tty3:respawn:/bin/getty 38400 tty3tty4:respawn:/bin/getty 38400 tty4# Stuff to do when restarting the init process:restart:/bin/init# Stuff to do before rebooting:ctrlaltdel:/bin/reboot:shutdown:/bin/umount -a -r:shutdown:/bin/swapoff -aissueZml Linux release 0.1motd(空文件)mtab(空文件)passwdroot:0:0:root:/root:/bin/ashprofile# /etc/profile: system-wide .profile file for the Bourne shellsechoechoexport PS1=uh w$echo Donealias ll=ls -lalias du=du -halias df=df -halias rm=rm -iechoresolv.confnameserver 2shadowroot1$adltAB9Sr/MSKqylIvSJT/:12705:0:99999:7:shadow-root1$DWU.tenP$B7ANiXoGoiZMwJR6Ih8810:12705:0:99999:7:四、 制作img映象文件把上面的文件系统做成img映像文件,以便内核把它载入ram中 linux下有很多ram,我用ram1,首先把ram1格式化成ext2文件系统 rootlocalhost /# mkfs.ext2 m 0 /dev/ram1mke2fs 1.35 (28-Feb-2004)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)4096 inodes, 16384 blocks0 blocks (0.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=167772162 block groups8192 blocks per group, 8192 fragments per group2048 inodes per groupSuperblock backups stored on blocks: 8193Writing inode tables: done Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 32 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override. 将ram1挂装到文件系统中: 先建立一个挂装点: #mkdir /mnt/ram 挂上ram1: #mount /dev/ram1 /mnt/ram 将先前做好的rootfs根文件系统拷贝到ram1上. #cp R /rootfs/* /mnt/ram 拷贝好根文件系统后卸载ram1: #umount /dev/ram1 再用dd把这个ram1以映象方式取出来: rootlocalhost /# dd if=/dev/ram1 of=initrd.img 读入了 8192+0 个块输出了 8192+0 个块 把生成的initrd.img和前面得到的bzImage文件一起拷到/boot即可 五、 利用grub启动rootlocalhost /# vi /boot/grub/grub.conf将grub.conf改写为:# grub.conf generated by anaconda# Note that you do not have to rerun grub after making changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/sda3# initrd /initrd-version.img#boot=/dev/sdadefault=1timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle Red Hat Enterprise Linux AS () root (hd0,0) kernel /vmlinuz- ro root=LABEL=/ rhgb quiet initrd /initrd-.imgtitle Red Hat Enterprise Linux AS (2.6.9-55.ELsmp) root (hd0,0) kernel /vmlinuz-2.6.9-55.ELsmp ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.9-55.ELsmp.imgtitle Red Hat Enterp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论