Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101902010
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-03-27 08:39:38

作者:skid  出处:linux.ccidnet.com   
 
1 建立根文件系统结构 


#mkdir rootfs 



#cd rootfs 


#mkdir bin dev etc lib proc sbin tmp usr var 


#chmod 1777 tmp 


#mkdir usr/bin usr/lib usr/sbin 


#mkdir var/lib var/lock var/log var/run var/tmp 


#chmod 1777 var/tmp 



2 准备链接库 


#cd ${OBJ_LIB}/lib (${OBJ_LIB}是交叉编译环境的目录) 


#for file in libc libcrypt libdl libm \ 


>libpthread libresolv libutil 


>do 


>cp $file-*.so /home/fortis/rootfs/lib 


>cp -d $file.so.[*0-9] /home/fortis/rootfs/lib 


>done 


#cp -d ld*.so* /home/fortis/rootfs/lib 



3 使用busybox制作系统应用程序 


3.1 下载busybox()并解压。 

3.2 进入解压后的目录,配置Busybox 

$make menuconfig 

Busybox Settings > 

General Configuration > 

[*] Support for devfs 

Build Options > 

[*] Build BusyBox as a static binary (no shared libs) 

/* 将busybox编译为静态连接,少了启动时找动态库的麻烦 */ 

[*] Do you want to build BusyBox with a Cross Compiler? 

(/usr/local/arm/3.3.2/bin/armlinux) 

Cross Compiler prefix/* 指定交叉编译工具路径 */ 

Init Utilities > 


[*] init 

[*] Support reading an inittab file 

/* 支持init读取/etc/inittab配置文件,一定要选上 */ 

Shells > 

Choose your default shell (ash) > 

/* (X) ash 选中ash,这样生成的时候才会生成bin/sh文件 

* 看看我们前头的linuxrc脚本的头一句: 

* #!/bin/sh 是由bin/sh来解释执行的 

*/ 

[*] ash 

Coreutils > 

[*] cp 

[*] cat 

[*] ls 

[*] mkdir 

[*] echo (basic SuSv3 version taking no options) 

[*] env 

[*] mv 

[*] pwd 

[*] rm 

[*] touch 

Editors > 

[*] vi 

Linux System Utilities > 

[*] mount 

[*] umount 

[*] Support loopback mounts 

[*] Support for the old /etc/mtab file 

Networking Utilities > 

[*] inetd 

/* 

* 支持inetd超级服务器 


*/ 

3.3 编译并安装Busybox 

$make TARGET_ARCH=arm CROSS=armlinux\ 

PREFIX=/home/arm/dev_home/rootfs/my_rootfs/ all install 

PREFIX指明安装路径:就是我们根文件系统所在路径。 


4 准备所需的设备文件 


可以直接拷贝宿主机上的,或者自建几个就是。 



#cd rootfs/dev 


#mknod -m 600 console c 5 1 


5 创建linuxrc文件 

内容如下: 

$ vim rootfs/linuxrc 

#!/bin/sh 


echo "Hello linux ,gggggg" 


exec /sbin/init 

然后修改权限:chmod 775 linuxrc 



6 制作initrd映象文件 


#mkdir initrd 


#dd if=/dev/zero of=initrd.img bs=1k count=8192 


#/sbin/mke2fs -F -v -m0 initrd.img 


#mount -o loop initrd.img initrd 


#cp -av rootfs/* initrd 


#umount 


#gzip -9 initrd.img 

 
阅读(206) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~