免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2028 | 回复: 5
打印 上一主题 下一主题

制作U盘启动 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-14 12:31 |只看该作者 |倒序浏览
USB Linux

系统的启动流程:
        开机--Bois自检(硬件检测)---init 19 ---读取第一个可以引导的设备的MBR--- GRUB读取grub.conf---grub根据配置文件加载指定的内核镜像,初始化内存盘----初始化内存盘驱动必要的硬件,然后内核加载----产生第一个进程init ---init /etc/inittab ,判断运行级别---init 运行 rc.sysinit脚本,进行系统初始化:读取fstab进行必要的挂载 ----进去相应的级别,加载对应级别的服务启动脚本,接着rc.local--》根据运行级别,产生不同的登录界面

#cat /etc/redhat-release
查看系统版本


制作步骤:
1;备份U盘数据,再破坏U盘数据

        dd if=/dev/sdb of=/tmp/sdb_mbr bs=512k count=1
        意思:假如sdb为U盘的话,读取sdb的前512k的内容,并且存到/tmp/sdb_mbr。即为备份MBR
        恢复MBR如下
        dd if=/tmp/sdb_mbr of=/dev/sdb

        破坏数据如下:
        dd if=/dev/zero of=/dev/sdb bs=512K count=1

        w95 FAT32<-----------------------------------------分区fdisk用b

        分区安排:
         /         512M (必须 “打*”)
         swap    256-512M(可选)
         使用剩余的空间作盘U盘使用的分区(只能在linux使用)

2、在U盘产生系统必要目录结构

        # rpm   -ivh --root=/mnt --nodeps  /share/rhel_source/Server/filesystem-2.4.0-2.i386.rpm

3、找到必要的工具和命令,安装到USB

        bash-3.2-24.el5

        基本操作命令 : cp mv ls
        # rpm -qf `which cp`
        coreutils-5.97-19.el5

        系统管理命令:  init  shutdown
        SysVinit-2.86-15.el5
       
        分区管理命令: fdisk mount
        util-linux-2.13-0.50.el5

        网络命令:ifconfig
        net-tools-1.60-78.el5

        进程管理命令: ps free top
        procps-3.2.7-11.1.el5

        文本终端下鼠标驱动:gpm-1.20.1-74.1

        portmap

        帐号验证相关 : /etc/passwd   ,  passwd  , shadow
        setup-2.5.58-4.el5
        passwd-0.73-1
        shadow-utils-4.0.17-14.el5

        编辑器:vim-enhanced-7.0.109-4.el5_2.4z

        yum install --installroot=/mnt bash coreutils SysVinit util-linux net-tools procps portmap setup passwd shadow-utils openssh-clients vim-enhanced gpm



        -----------------
        可选:
        openssh-server-4.3p2-29.el5
        openssh-clients-4.3p2-29.el5


        安装完必须同步数据一次
        sync

        4、产生一个initrd镜像文件
        # mkinitrd --with usb_storage  /mnt/boot/initrd  `uname -r`


        5、拷贝内核镜像和内核对应的模块文件

        # cp /boot/vmlinuz-2.6.18-128.el5 /mnt/boot/vmlinuz

        # cp /lib/modules/2.6.18-128.el5/   /mnt/lib/modules/ -r

        # sync

        5、安装grub
        # rpm -ivh --force --nodeps  --nopre  --nopost --root=/mnt/  /share/rhel_source/Server/grub-0.97-13.2.i386.rpm

        安装grub的第一阶段的引导程序到mrb里(1-446字节)

        [root@dns usb]# grub-install --root-directory=/usb --recheck /dev/sdb
        grep: /mnt/usb/boot/grub/device.map: 没有那个文件或目录
        mv: 无法 stat “/mnt/usb/boot/grub/device.map”: 没有那个文件或目录
        Probing devices to guess BIOS drives. This may take a long time.
        Installation finished. No error reported.  《————— 看这里
        This is the contents of the device map /mnt/usb/boot/grub/device.map.
        Check if this is correct or not. If any of the lines is incorrect,
        fix it and re-run the script `grub-install'.

        (fd0)   /dev/fd0
        (hd0)   /dev/sda
        (hd1)   /dev/sdb


        # vim /mnt/boot/grub/device.map
        (hd0)   /dev/sdb

        # vim /mnt/boot/grub/grub.conf
        default=0
        timeout=8

        title Usb Linux
        root (hd0,0)
        kernel /boot/vmlinuz
        initrd /boot/initrd


        6、设置U盘root密码
        chroot /mnt
        pwconv
        passwd root
        cat /etc/shadow
        exit

        # cp /etc/skel/.bash*  /mnt/root/

        # sync

论坛徽章:
0
2 [报告]
发表于 2010-04-14 12:47 |只看该作者
学习了

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
3 [报告]
发表于 2010-04-14 13:00 |只看该作者
复杂。。。。直接量产 简单。。。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
4 [报告]
发表于 2010-04-14 17:01 |只看该作者
复杂。。。。直接量产 简单。。。
dooros 发表于 2010-04-14 13:00



   

论坛徽章:
0
5 [报告]
发表于 2010-04-14 17:28 |只看该作者
{:3_188:}

论坛徽章:
0
6 [报告]
发表于 2010-04-14 17:29 |只看该作者
量产?不会。。能教教我不?我是新手来着
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP