加载中…
个人资料
散人
散人
  • 博客等级:
  • 博客积分:0
  • 博客访问:15,610
  • 关注人气:4
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

10 关于rootfs部分脚本代码的分析 [1]

(2011-09-26 14:49:26)
标签:

linux

# pwd
/etc
# ls
fs-version    inittab       mtab          profile_lirc
fstab         lircd.conf    passwd        profile_std
group         mactab        passwd-       protocols
init.d        memstat.conf  profile       services
# vi inittab

::sysinit:/etc/init.d/rcS # telnetd和命令行解析

::respawn:/sbin/getty -L ttyAMA0 115200 vt100 -n root -I "Auto login as root ... #创建一个可重生的串口终端

::restart:/sbin/init

::ctrlaltdel:/sbin/reboot                                                      
::shutdown:/bin/umount -a -r                                                   
::shutdown:/sbin/swapoff -a

# pwd
/etc/init.d
# ls
autorun       autorun_lirc  autorun_std   rcS
# vi rcS #系统初始化时启动参数中rootfs的识别

脚本代码如下:

#! /bin/sh                                                                     
                                                                               
/bin/mount -a                                                                  
                                                                               
mknod /dev/ttyAMA0 c 204 64                                                    
mknod /dev/ttyAMA1 c 204 65                                                    
                                                                               
BOARD_INIT="/etc/init.d/autorun"                                               
[ -x $BOARD_INIT ] && eval $BOARD_INIT                                         
                                                                               
get_cmdline()                                                                  
                                                                             
        echo "${CMD_LINE}" | grep "^${1}=" | sed -n "s/^${1}=//p"              
  

                                                                                 
#支持从启动参数配置IP方法                                                                 
if [ -x /bin/grep ] && [ -x /bin/sed ] ;                                       
then                                                                           
        CMD_LINE="`cat /proc/cmdline | sed -n "s/\ /\n/gp"`"                   
        if [ -n "`cat /proc/cmdline | grep "root=.*nfs .*\<nfsroot="`" ] ;     
        then                                                                   
                echo "Using NFS as RootFS"                                     
        else                                                                   
                echo "Checking for boardip ..."

                BOARD_IP="`get_cmdline boardip`"                         
                if [ -n "${BOARD_IP}" ] ;                                
                then                                                     
                        /sbin/ifconfig eth0 up ${BOARD_IP} netmask 255.0.0.0
                        echo "Auto set board ip as ${BOARD_IP}"            
                fi                                                         
        fi                                                                 
fi                                                                         
                                                                           
if [ -x /usr/sbin/telnetd ] ;                                              
then                                                                       
        telnetd&     #开启telnetd 后台运行                                                      
fi         

 

#cat /proc/cmdline

mem=20M console=ttyAMA0,115200 video=4 bootstrap=softmce mmz=msg_buf,2,0x61400000,0xf4000;frm_buf,2,0x614f4000,0x260000;aud_pes,2,0x61754000,0x20000;vid_pes,2,0x61774000,0x40000;vo_osd,2,0x617b4000,0x10000;vo_still,2,0x617c4000,0x10000;jpeg,2,0x617d4000,0x380000;dmx_buf,2,0x61b54000,0x7d000;others,2,0x61bd1000,0x3b0000 rootfstype=cramfs mtdparts=hisilicon:384k(Boot),128k(e2),1m(kernel),832k(rootfs),2m(syslogs),-(apps) root=/dev/mtdblock/3 lpj=577536  未配置IP的启动项

 

set bootargs 'mem=20M console=ttyAMA0,115200 video=4 bootstrap=softmce mmz=msg_buf,0xf4000;frm_buf,0x260000;aud_pes,0x20000;vid_pes,0x40000;vo_osd,0x10000;vo_still,0x10000;jpeg,0x380000;dmx_buf,0x7D000;others,0x3b0000 rootfstype=cramfs mtdparts=hisilicon:384k(Boot),128k(e2),1m(kernel),832k(rootfs),2m(syslogs),-(apps) root=/dev/mtdblock/3 lpj=577536 boardip=192.168.1.238'           配置IP为192.168.1.238的启动项

 

#vi autorun

脚本代码如下:设备驱动模块加载

mount -t tmpfs nodev /var              
mkdir -p /var/tmp                                                           
mount /dev/mtdblock/4 /database -t jffs2
mount /dev/mtdblock/5 /mnt 
insmod /kmod/hi_dmac.ko 
insmod /kmod/hi_tde.ko  
insmod /kmod/hi_mpi.ko   
insmod /kmod/hi_i2c.ko  
insmod /kmod/hi_tuner.ko
insmod /kmod/hi_wdg.ko                   
insmod /kmod/hi_e2prom.ko
insmod /kmod/hi_keyled.ko
insmod /kmod/hi_rtc.ko  
insmod /kmod/hi_ir.ko   
insmod /kmod/hi_sci.ko  
insmod /kmod/hi_pmoc.ko 
insmod /kmod/fb.ko      
insmod /kmod/hifb.ko                      
mknod /dev/vo c 244 0   
mknod /dev/audio c 243  0
mknod /dev/video c 242  0
mknod /dev/sync c  241  0
mknod /dev/demux c 240  0
mknod /dev/vbi c 246 0                        
mknod /dev/tde c 245  
rm -f /var/tmp/*        

0

阅读 收藏 禁止转载 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

新浪公司 版权所有