文件系统制作

来源:互联网 发布:java websocket 框架 编辑:程序博客网 时间:2024/04/29 23:32

终于得到一个不会提示出错的文件系统了,真郁闷。。还是从网上down了一个文件系统,在它的基础上修改。


最开始启动的时候出现了错误,再重启以后ls,cd等命令都可以用了。好像是刚开始启动的时候速度过慢的原因。

另外今天发现了一个问题,当不使用额外的Linuxrc脚本时,系统正确启动,而一旦增加了linuxrc脚本,

就出现找不到etc/init.d/rcS脚本以及很多错误提示,不知道这是什么原因?

虽然这个文件系统不完全是自己制作的,但在文件系统上花了我实在是太多的时间了。可能就是Linurc这个脚本问题一直导致出错!!

下面记录一下文件系统的制作过程。采用busybox1.9.2 动态库编译。

修改makefile .主要还是改编译器路径。执行Make menuconfig

Busybox Settings ­­­>

General Configuration ­­­>

[*] Support for devfs 这一项一定要选上

Build Options ­­­>

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

/* 将 busybox 编译为静态连接,少了启动时找动态库的麻烦 到目前为止 动态编译还没成功过*/ 如果选择静态库,那么就不用拷贝lib文件,但这样的话应用程序就不能运行了。*/

选动态库。

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

(/usr/local/arm/3.3.2/bin/arm­linux­) 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 超级服务器

* inetd 的配置文件为/etc/inetd.conf 文件,

* "在该部分的 4: 相关配置文件的创建"一节会有说明

*/


得到install文件夹。下一步构建根文件系统的基本目录,采用脚本的方式,


#!/bin/sh

echo "makeing dir: bin dev etc lib proc sbin sys usr"

mkdir bin dev etc lib proc sbin sys usr #8 dirs

mkdir usr/bin usr/lib usr/sbin lib/modules


#Don't use mknod, unless you run this Script as 节点要root用户才能建立。

# mknod -m 600 dev/console c 5 1

#mknod -m 666 dev/null c 1 3


echo "making dir: mnt tmp var"

mkdir mnt tmp var

chmod 1777 tmp

mkdir mnt/etc mnt/jiffs2 mnt/yaffs mnt/data mnt/temp

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

chmod 1777 var/tmp

echo "making dir: home root boot"

mkdir home root boot

echo "done"

得到了基本目录以后,将install文件夹下的内容拷贝过来

cp -a install/* /home/tangcong/working/share


这里不需要Linuxrc脚本,前面提到了老是出错。主要要创建是etc目录下的配置文件。

tangcong@tangcong-laptop:~/working/share/etc$ ls

fstab gshadow inittab mtab pointercal shadow

group init.d mdev.conf passwd profile

其中inittab,fstab,profile等内容基本差不多,还有init.d目录下的rcS脚本。可根据自己的需求修改。

inittab中内容为:::sysinit:/etc/init.d/rcS

::respawn:-/bin/login

::restart:/sbin/init


tty0::respawn:-/bin/login


::ctrlaltdel:/sbin/reboot

::shutdown:/bin/umount -a -r

::shutdown:/sbin/swapoff -a


fstab内容:

proc /proc proc defaults 0 0

none /tmp ramfs defaults 0 0

none /dev/pts devpts mode=0622 0 0

tmpfs /dev/shm tmpfs defaults 0 0

sysfs /sys sysfs defaults 0 0


profile内容:

# /etc/profile: system-wide .profile file for the Bourne shells


echo

echo "Processing /etc/profile..."

# no-op

# Set search library path

echo "Set search library path"

export LD_LIBRARY_PATH=/lib:/usr/lib


# Set user path

echo "Set user path"

PATH=/bin:/sbin:/usr/bin:/usr/sbin

export PATH


# Set PS1

#注意:ash 除了SHELL变量外,支持\u\h\W\$\!\n\w \nnnASCII字符对应的八进制数)

#以及\e[xx;xxm (彩色特效)等等!

#而且前面还要多加一个 '\'


echo "Set PS1"

export PS1="\\e[05;32m[$USER@\\w\\a]\\$\\e[00;34m"


echo "Set ENV for tslib......"

export TSLIB_ROOT=/lib/tslib

export TSLIB_TSDEVICE=/dev/event0

export TSLIB_CALIBFILE=/etc/pointercal

export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf

export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts

export TSLIB_CONSOLEDEVICE=none

export TSLIB_FBDEVICE=/dev/fb0

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib


echo "/etc/profile Done!"

#echo


rcS内容:

#! /bin/sh

#! /bin/sh

echo "----------mount all"

/bin/mount -a



echo "----------Starting mdev......"

/bin/mount -t ramfs mdev /dev

/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug

mdev -s



echo "********************************************"

echo " still learning"

echo " Love Linux ! "

echo "********************************************"


然后将主机下的passwd,shadow,group文件拷过来。并修改成如下的形式。也可根据自己的需要来增加用户。

Passwd root:x:0:0:root:/root:/bin/sh

Shadow root::14379:0:99999:7::: 第一个冒号跟第二个冒号之间没有数字时表示不需要密码,按enter键可直接登录。

Group root:x:0:root

怎么增加用户?


拷贝库文件。将arm/3.4.1/arm-linux/lib目录下的文件拷过来

一种简单的方法就是 cp -a l*so* .的形式现将所有的文件都拷过来,再删除不需要的。不过libm libc libcrypt ld-linux-so是必须的。


最后就是一个权限问题。Chmod 777 rcS就可以了。


开发板上电启动,成功。接下来就移植qtopiatslib,文件系统就先告一段落了。2009626日唐聪于实验室记录。

0 0