[UP] add some viki files, knowledge.
[arrow.git] / viki / ramdisk / busybox-ramdisk.viki
blobdf84052d1e4bbedf141c9e7e9e137493da1de8a3
1 ref: http://tech.ddvip.com/2007-04/117758451623217.html
2 Linux下用Busy Box制作Ramdisk全过程
3 3G双线全能空间1元 开网店-找友创互联 0元招收代理【CN域名0.5元】
5 http://tech.ddvip.com   2007年04月26日    社区交流
6 关键字: Linux on Power GDB UNIX 进程 共享上网设置 Linux无法引导 NTP服务
7 本文详细介绍Linux下用Busy Box制作Ramdisk全过程
9   1 建立根文件系统结构
11   #mkdir rootfs
13   #cd rootfs
15   #mkdir bin dev etc lib proc sbin tmp usr var
17   #chmod 1777 tmp
19   #mkdir usr/bin usr/lib usr/sbin
21   #mkdir var/lib var/lock var/log var/run var/tmp
23   #chmod 1777 var/tmp
25   2 准备链接库
27   #cd ${OBJ_LIB}/lib (${OBJ_LIB}是交叉编译环境的目录)
29   #for file in libc libcrypt libdl libm
31   >libpthread libresolv libutil
33   >do
35   >cp $file-*.so /home/fortis/rootfs/lib
37   >cp -d $file.so.[*0-9] /home/fortis/rootfs/lib
39   >done
41   #cp -d ld*.so* /home/fortis/rootfs/lib
43   3 使用busybox制作系统应用程序
45   3.1 下载busybox(http://www.busybox.net/)并解压。
47   3.2 进入解压后的目录,配置Busybox
49   $make menuconfig
51   Busybox Settings >
53   General Configuration >
55   [*] Support for devfs
57   Build Options >
59   [*] Build BusyBox as a static binary (no shared libs)
61   /* 将busybox编译为静态连接,少了启动时找动态库的麻烦 */
63   [*] Do you want to build BusyBox with a Cross Compiler?
65   (/usr/local/arm/3.3.2/bin/armlinux)
67   Cross Compiler prefix/* 指定交叉编译工具路径 */
69   Init Utilities >
71   [*] init
73   [*] Support reading an inittab file
75   /* 支持init读取/etc/inittab配置文件,一定要选上 */
77   Shells >
79   Choose your default shell (ash) >
81   /* (X) ash 选中ash,这样生成的时候才会生成bin/sh文件
83   * 看看我们前头的linuxrc脚本的头一句:
85   * #!/bin/sh 是由bin/sh来解释执行的
87   */
89   [*] ash
91   Coreutils >
93   [*] cp
95   [*] cat
97   [*] ls
99   [*] mkdir
101   [*] echo (basic SuSv3 version taking no options)
103   [*] env
105   [*] mv
107   [*] pwd
109   [*] rm
111   [*] touch
113   Editors >
115   [*] vi
117   Linux System Utilities >
119   [*] mount
121   [*] umount
123   [*] Support loopback mounts
125   [*] Support for the old /etc/mtab file
127   Networking Utilities >
129   [*] inetd
131   /*
133   * 支持inetd超级服务器
135   */
137   3.3 编译并安装Busybox
139   $make TARGET_ARCH=arm CROSS=armlinux
141   PREFIX=/home/arm/dev_home/rootfs/my_rootfs/ all install
143   PREFIX指明安装路径:就是我们根文件系统所在路径。
145   4 准备所需的设备文件
147   可以直接拷贝宿主机上的,或者自建几个就是。
149   #cd rootfs/dev
151   #mknod -m 600 console c 5 1
153   5 创建linuxrc文件
155   内容如下:
157   $ vim rootfs/linuxrc
159   #!/bin/sh
161   echo "Hello linux ,gggggg"
163   exec /sbin/init
165   然后修改权限:chmod 775 linuxrc
167   6 制作initrd映象文件
169   #mkdir initrd
171   #dd if=/dev/zero of=initrd.img bs=1k count=8192
173   #/sbin/mke2fs -F -v -m0 initrd.img
175   #mount -o loop initrd.img initrd
177   #cp -av rootfs/* initrd
179   #umount
181   #gzip -9 initrd.img
183 ----8<----
184 # use busybox generate rootfs
185 http://blog.chinaunix.net/u1/55623/showart_436042.html
187 # use skyeye run armlinux
188 http://blog.chinaunix.net/u2/78225/showart_1226094.html
190 # make cpio initrd
191 http://www.diybl.com/course/6_system/linux/Linuxjs/200866/123072.html
193 # write initrd into vmlinuz
194 http://www.91linux.com/html/article/qianrushiyingyong/20081110/13740.html
196 # understand initrd more
197 http://blog.linux.org.tw/~jserv/archives/001954.html