分类: LINUX
2008-05-07 22:49:46
#!/bin/sh
BUSYBOX=/scratchbox/source2/busybox/busybox-1.1.2
COMPILER_PREFIX=/scratchbox/compilers/arm-linux-gcc-3.4.4-glibc-2.3.5/arm-unknown-linux-gnu/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-
COMPILER_LIB=/scratchbox/compilers/arm-linux-gcc-3.4.4-glibc-2.3.5/arm-unknown-linux-gnu/lib
if test "$1" = ""; then
CLFS_ROOTFS_DIR=rootfs
echo "CLFS_ROOTFS_DIR=$CLFS_ROOTFS_DIR"
else
CLFS_ROOTFS_DIR=$1
echo "CLFS_ROOTFS_DIR=$CLFS_ROOTFS_DIR"
fi
echo "Create a standard directory tree. . ."
echo "The directory tree is based on the Filesystem Hierarchy Standard (FHS) (available at )"
echo ""
mkdir -pv ${CLFS_ROOTFS_DIR}/{bin,boot,dev,{etc/,}opt,home,lib}
mkdir -pv ${CLFS_ROOTFS_DIR}/mnt/{etc,jffs2,yaffs,tmp,gpephone,enlightenment}
mkdir -pv ${CLFS_ROOTFS_DIR}/{proc,media,sbin,srv,sys}
mkdir -pv ${CLFS_ROOTFS_DIR}/var/{lock,log,mail,run,spool}
mkdir -pv ${CLFS_ROOTFS_DIR}/var/{opt,cache,lib/{misc,locate},local}
install -dv -m 0750 ${CLFS_ROOTFS_DIR}/root
install -dv -m 1777 ${CLFS_ROOTFS_DIR}{/var,}/tmp
mkdir -pv ${CLFS_ROOTFS_DIR}/usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv ${CLFS_ROOTFS_DIR}/usr/{,local/}share/{doc,info,locale,man}
mkdir -pv ${CLFS_ROOTFS_DIR}/usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv ${CLFS_ROOTFS_DIR}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
for dir in ${CLFS_ROOTFS_DIR}/usr{,/local}; do
ln -sfnv share/{man,doc,info} ${dir}
done
安装:busybox
Busybox Settings --->
Installation Options --->
[*] Don't use /usr
(/home/tekkamanninja/working/nfs/rootfs) BusyBox installation prefix
Busybox Library Tuning --->
[*] Support for /etc/networks
[*] Additional editing keys
[*] vi-style line editing commands
(15) History size
[*] History saving
[*] Tab completion
[*] Username completion
[*] Fancy shell prompts
Login/Password Management Utilities --->选项全部N掉,后面单独使用TinyLogin
Linux Module Utilities --->
[N] Support version 2.2.x to 2.4.x Linux kernels
Shells --->
--- Ash Shell Options 下的选项全选
[sbox-rootfs: /scratchbox/source2/busybox/busybox-1.9.0] > make
[sbox-rootfs: /scratchbox/source2/busybox/busybox-1.9.0] > make PREFIX=/ install
补充:
在scratchbox中如果:make menuconfig 出现can't found -lncurse 那么请安装ncurse库
ftp://invisible-island.net/ncurses/ncurses-5.5.tar.gz
./configure --prefix=$PREFIX --with-shared --without-debug --without-ada --enable-overwrite
编译sysvinit
sysvinit-2.86
修改src下的Makefile文件,去掉root权限限制,否则sb中安装不了
cd sysvinit-2.86/src
make && make install
安装的文件
/sbin/bootlogd
/sbin/halt
/sbin/init
/sbin/killall5
/sbin/poweroff -> halt
/sbin/reboot -> halt
/sbin/runlevel
/sbin/shutdown
/sbin/telinit -> init
/bin/mountpoint
/bin/pidof -> ../sbin/killall5
注意
如果/etc/inittab 文件格式不正确那么会出现
INIT: no more processes left in this runlevel
加上1:2345:respawn:/bin/sh 可以修正这个错误
如果有:
S:2345:respawn:/sbin/getty 115200 ttyS0
1:2345:respawn:/sbin/getty 38400 tty1
那么将进不了控制台
注意:
busybox 与 sysvinit 两种inittab文件格式的不同
init都是通过读取/etc/inittab文件决定要执行那些初始化脚本和程序
读取 /etc/inittab 文件中的 si::sysinit:/etc/init.d/rcS 执行/etc/rcS.d/脚本
读取 /etc/inittab 文件中的 id:5:initdefault: 来执行/etc/rc$x.d下面的脚本
内核的init/main.c 中sys_open 了 设备 /dev/console
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");
执行/linuxrc文件
linux-2.6.14/init/mian.c
init()
prepare_namespace()
initrd_load()
handle_initrd()
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
从/mian.c 中的init()函数可以看出 /linuxrc 文件的执行在 文件系统的 init执行之前
安装tinylogin
修改src下的install.sh文件,去掉root权限限制,否则sb中安装不了
cd tinylogin-1.4
make && make PREFIX=/ install
/bin/addgroup -> tinylogin
/bin/adduser -> tinylogin
/bin/delgroup -> tinylogin
/bin/deluser -> tinylogin
/bin/login -> tinylogin
/bin/su -> tinylogin
/sbin/getty -> ../bin/tinylogin
/sbin/sulogin -> ../bin/tinylogin
/usr/bin/passwd -> ../../bin/tinylogin
/usr/bin/vlock -> ../../bin/tinylogin
要使用tinylogin登录那么需要把/etc/inittab 文件的
1:2345:respawn:/bin/sh 用 1:2345:respawn:/bin/login替代
安装:TinyLogin
如果login的时候出现login: no valid shadow password 所以一定用下面的tinylogin
指明tinyLogin使用自己的算法来处理用户密码
vim Makefile
USE_SYSTEM_PWD_GRP = false
. . .
CROSS =$COMPILER_PREFIX
CC = $(CROSS)gcc
AR = $(CROSS)ar
STRIPTOOL = $(CROSS)strip
或者直接
export PATH=/usr/local/arm/arm-linux-gcc-3.4.4-glibc-2.3.5/bin/:$PATH
make CROSS=arm-unknown-linux-gnu-
sudo make PREFIX=/nfsroot/rootfs install
/nfsroot/rootfs/bin/addgroup -> tinylogin
/nfsroot/rootfs/bin/adduser -> tinylogin
/nfsroot/rootfs/bin/delgroup -> tinylogin
/nfsroot/rootfs/bin/deluser -> tinylogin
/nfsroot/rootfs/bin/login -> tinylogin
/nfsroot/rootfs/bin/su -> tinylogin
/nfsroot/rootfs/sbin/getty -> ../bin/tinylogin
/nfsroot/rootfs/sbin/sulogin -> ../bin/tinylogin
/nfsroot/rootfs/usr/bin/passwd -> ../../bin/tinylogin
/nfsroot/rootfs/usr/bin/vlock -> ../../bin/tinylogin
创建修改必要的文件:
cp $BUSYBOX/examples/bootfloppy/etc/* ${CLFS_ROOTFS_DIR}/etc/ -rv
vim ${CLFS_ROOTFS_DIR}/etc/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 in /etc/profile"
export LD_LIBRARY_PATH=/lib:/usr/lib
# Set user path
echo "Set user path in /etc/profile"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
# Set PS1
#注意:ash 除了SHELL变量外,支持\u、\h、\W、\$、\!、\n、\w 、\nnn(ASCII字符对应的八进制数)
#以及\e[xx;xxm (彩色特效)等等!
#而且前面还要多加一个 '\'!
echo "Set PS1 in /etc/profile"
export PS1="\\e[05;32m[$USER@\\w\\a]\\$\\e[00;34m"
echo "Done"
----------------------------------
修改初始化文件
vim ${CLFS_ROOTFS_DIR}/etc/inittab
----------------------------------
::sysinit:/etc/init.d/rcS
::respawn:-/bin/login
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
----------------------------------
使用login登录,如果直接进入sh,那么修改
::respawn:-/bin/login -> ::respawn:-/bin/sh
vim ${CLFS_ROOTFS_DIR}/etc/fstab
----------------------------------
proc /proc proc defaults 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
----------------------------------
修改初始化脚本
vim ${CLFS_ROOTFS_DIR}/etc/init.d/rcS
----------------------------------
#! /bin/sh
echo "------>mount all"
/bin/mount -a
echo "------>Starting mdev......"
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "********************************************************"
echo " hfrk s3c24xx rootfs (nfs) "
echo " Created by mohuifu 2008.04.30 "
echo "********************************************************"
-----------------------------------
mount -a 命令挂载 etc/fstab 中设定的分区
为mdev创建配置文件
vim ${CLFS_ROOTFS_DIR}/etc/mdev.conf
内容可无,也可参照规则填写
如果/etc/inittab 中有