Chinaunix首页 | 论坛 | 博客
  • 博客访问: 288507
  • 博文数量: 103
  • 博客积分: 2345
  • 博客等级: 大尉
  • 技术积分: 902
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-01 09:10
文章分类

全部博文(103)

文章存档

2022年(1)

2018年(3)

2017年(2)

2016年(3)

2015年(8)

2014年(8)

2013年(2)

2012年(9)

2011年(29)

2010年(20)

2009年(18)

我的朋友

分类:

2009-10-14 16:53:38

五.制作文件系统 (这一步主要参http://blog.linuxmine.com/html/34/6534_itemid_861.html 谢谢GuCuiwen)
这是比较麻烦的一步,我弄了好久,看了挺多网上的文章,但总是不对。
建一个目录rootfs 用来装文件系统
#mkdir etc usr var tmp proc home root dev //建立文件目录
其中etc,proc和dev是一定要建的,bin和sbin可以拷贝busybox生成的,其他的可以象征性的建几个就可以了.
 
拷贝busybox下的_install文件夹到rootfs下
#cp -R busybox-1.00/_install/* rootfs/
 
在dev文件夹下建立设备文件名:
#cd rootfs/dev
为了方便我们直接从原系统的/dev目录下拷贝过来.一定要叫-r参数
 
#cp -R /dev/console ./
#cp -R /dev/null ./
#cp -R /dev/zero ./
...
其中,fd0,hda,ram,ram1,tty1,null,zero,loop1,fb0,fb,tty(这个GuCuiwen文章中没有,但我觉得要加)等是必备的.
其它的hda,hda1,hdb等可以根据实际需要决定.但是上表中的选择是比较合理的,即能满足大部分的需要,
 
建立etc目录下的配置文件
 
busybox.conf group inittab motd passwd resolv.conf shadow-
fstab init.d issue mtab profile shadow
 
其中init.d是一个目录,从busybox-1.00源代码目录下拷贝过来.
#cp -R busybox-1.00/examples/bootflopyp/etc/init.d rootfs/etc/
 
把init.d拷过来后要更改其中的文件rcS:
请确保这个文件是可执行的,否则请改成可执行的:
#chmod u+x rcS
 
用记事本打开rcS的内容:
 
 
#! /bin/sh
mount -o remount,rw /
/bin/mount -a
>/etc/mtab
echo
echo
echo
echo
echo -en "\t\tWelcom to lxh Linux\\033][0;39m\n"
hostname LxhLinux
 
echo后面跟的都是系统可以自己作相应的修改.
busybox.conf是一个空文件.
其他文件的内容如下:
 
 
fstab
/dev/fd0 / ext2 defaults 0 0
none /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 0
group
root:0:root
inittab
::sysinit:/etc/init.d/rcS
::askfirst:/bin/sh
tty2::respawn:/bin/getty 38400 tty2
tty3::respawn:/bin/getty 38400 tty3
tty4::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 -a
issue
Baby Linux release 0.1
motd
mtab
passwd
root::0:0:root:/root:/bin/ash
profile
# /etc/profile: system-wide .profile file for the Bourne shells
echo
echo
export PS1="[\u@\h \w]\___FCKpd___1quot;
echo "Done"
alias ll='ls -l'
alias du='du -h'
alias df='df -h'
alias rm='rm -i'
echo
resolv.conf
nameserver 192.168.1.12
shadow
root1$adltAB9Sr/MSKqylIvSJT/:12705:0:99999:7:::
shadow-
root1$DWU.tenP$B7ANiXoGoiZMwJR6Ih8810:12705:0:99999:7:::
 
六.制作img映象文件
 
把上面的文件系统做成img映像文件,以便内核把它载入ram中
linux下有很多ram,我们用ram1,首先把ram1格式化成ext2文件系统
[root@gucuiwen babylinux]# mkfs.ext2 -m0 /dev/ram1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
1024 inodes, 4096 blocks
0 blocks (0.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
1024 inodes per group
 
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 37 mounts or
180 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以映象方式取出来:
[root@gucuiwen babylinux]# dd if=/dev/ram1 of=initrd.img
读入了 8192+0 个块输出了 8192+0 个块
把生成的initrd.img拷到一个地方备用
 
七.制作grub启动光盘
首先下载grub安装文件,我下的是0。96版的grub。
tar zxvf grub-0.95.tar.gz //解开grub
cd grub-0.95
./configure
make
make install
 
好了,grub安装完成。安装完成后得到了最重要的stage2_eltorito 我们把它拷出来备用。
现在开始制作启动光盘:
mkdir iso ////建立iso文件夹,我们把所要的文件拷进这个文件夹
 
mkdir -p iso/boot/grub
 
cp /stage2_eltorito所在的路径/stage2_eltorito iso/boot/grub ////把stage2_eltorito文件拷入grub文件夹中
 
cp /boot/grub/menu.lst iso/boot/grub
 
cp /boot/grub/grub.conf iso/boot/grub
////把grub所用的启动文件grub.conf,menu.lst 拷入grub文件夹
 
下面我们更改menu.lst中的内容
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/hda1
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=1
timeout=10
title I love lxh ^_^ //显示在选项上的标题
root (cd)
kernel /boot/grub/vmlinuz-2.6.20 ro root=/dev/ram0
initrd /boot/grub/initrd.img
要更改的内容我用红色表示了,cd表示从光驱启动,/boot/grub/vmlinuz-2.6.20表示内核文件vmlinuz-2.6.20在光盘上存放的路径,/dev/ram0表示根文件目录的位置,由于我们是从光盘启动,启动时所有文件系统都拷入了ram,所以这里我们从ram0启动。 /boot/grub/initrd.img是我们上一步我们做的镜像文件存放在光盘的位置
 
八,集成,刻录
 
下面我们把所制作的文件全部集成在一起
iso-》boot -》grub -》grub.conf
iso-》boot -》grub -》menu.lst
iso-》boot -》grub -》stage2_eltorito
iso-》boot -》grub -》vmlinuz-2.6.20
iso-》boot -》grub -》initrd.img
 
vmlinuz-2.6.20,和 initrd.img可以不放在这里,若更改了存放路径则grub.conf中也要更改。
 
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o grub.iso iso
////这步的意思是把iso文件夹中的内容做成一个镜像,-b参数是表示做一个启动盘 ,其他的东西我也不太明白,如果哪位高手知道-no-emul-boot -boot-load-size 4 -boot-info-table是什么意思希望mail我。
 
好了,现在grub.iso就是你所需要的镜像了,我们可以先放到虚拟机的光驱中看看它是不是能够引导系统。如果不能仔细检查没一步。注意 grub.iso不能用winiso制作,原因好像是winiso做的iso文件缺少了光盘信息。但我们可以用demotools载入grub.iso文件,然后用全盘复制的方式刻录一张光盘linux。

本文来自: IT知道网() 详细出处参考:
阅读(1350) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:c语言中的逗号表达式

给主人留下些什么吧!~~