1. 编译bin等工具
下载所需的busy-box,
git clone git://git.busybox.net/busybox
编译出现
==============================================
Makefile:422: *** mixed implicit and normal rules: deprecated syntax
Makefile:1270: *** mixed implicit and normal rules: deprecated syntax
make: *** No rule to make target 'menuconfig'. Stop.
==============================================
错误原因:make的版本与Makefile所需的版本不一致。
解决方案:使用最新的busy-box的代码。
cd /dev/
sudo mknod -m 660 console c 204 64
sudo mknod -m 660 null c 1 3
3. 准备配置文件
/linuxrc:
#!/bin/sh
echo "Processing /linuxrc"
echo "mount /etc as ramfs"
/bin/mount -n -t ramfs ramfs /etc
/bin/cp -a /mnt/etc/* /etc
echo "re-create the /etc/mtab entries"
/bin/mount -f -t cramfs -o remount,ro /dev/bon/3 /
/bin/mount -f -t ramfs ramfs /etc
echo "start init"
exec /sbin/init
/mnt/etc/init.d/rcS
#!/bin/sh
echo "Processing /etc/init.d/rcS"
echo "mount -a"
mount -a #mount上fstab文件中所有文件系统
exec /etc/rc.local
/mnt/etc/rc.local:
#!/bin/sh
echo "Processing /etc/rc.local"
echo "get hostname"
/bin/hostname -F /etc/hostname
echo "Starting mdev"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "ifconfig eth0 192.168.1.21"
ifconfig eth0 192.168.1.21
echo "**************************************************"
echo "* *"
echo "* Linux ubuntu 2.6.32-30-generic *"
echo "* *"
echo "* arm-linux-gnueabi-gcc 4.4.5 *"
echo "* *"
echo "* 2011-04-04 *"
echo "* *"
echo "**************************************************"
/mnt/etc/profile
#/etc/profile
echo "Processing /etc/profile"
echo "set user path"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
echo "set search library path"
LD_LIBRARY_PATH=/lib:/usr/lib
echo "set PS1"
HOSTNAME=`/bin/hostname`
PS1='\u@\h:\w\$ ' #设置命令提示符为ubuntu风格
export PATH LD_LIBRARY_PATH HOSTNAME PS1
/mnt/etc/inittab:
#/etc/inittab
::sysinit:/etc/init.d/rcS
console::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
/mnt/etc/fstab:
#/etc/fstab: static file system information.
#<File system> <mount pt> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
mdev /dev ramfs defaults 0 0
none /tmp ramfs defaults 0 0
/etc/passwd
#username:password:User ID:Group ID:comment:home directory:shell
root:x:0:0:root:/root:/bin/sh
修改权限:
chmod 775 linuxrc mnt/etc/init.d/rcS mnt/etc/rc.local mnt/etc/profile
5. 生成ramfs,CramFS。
$mkcramfs rootfs/ rootfs.img
下载所需的busy-box,
git clone git://git.busybox.net/busybox
编译出现
==============================================
Makefile:422: *** mixed implicit and normal rules: deprecated syntax
Makefile:1270: *** mixed implicit and normal rules: deprecated syntax
make: *** No rule to make target 'menuconfig'. Stop.
==============================================
错误原因:make的版本与Makefile所需的版本不一致。
解决方案:使用最新的busy-box的代码。
创建目录:
#mkdir rootfs
#cd rootfs
#mkdir bin dev etc lib proc sbin sys usr mnt tmp var
#mkdir usr/bin usr/lib usr/sbin lib/modules
cd /dev/
sudo mknod -m 660 console c 204 64
sudo mknod -m 660 null c 1 3
3. 准备配置文件
/linuxrc:
#!/bin/sh
echo "Processing /linuxrc"
echo "mount /etc as ramfs"
/bin/mount -n -t ramfs ramfs /etc
/bin/cp -a /mnt/etc/* /etc
echo "re-create the /etc/mtab entries"
/bin/mount -f -t cramfs -o remount,ro /dev/bon/3 /
/bin/mount -f -t ramfs ramfs /etc
echo "start init"
exec /sbin/init
/mnt/etc/init.d/rcS
#!/bin/sh
echo "Processing /etc/init.d/rcS"
echo "mount -a"
mount -a #mount上fstab文件中所有文件系统
exec /etc/rc.local
/mnt/etc/rc.local:
#!/bin/sh
echo "Processing /etc/rc.local"
echo "get hostname"
/bin/hostname -F /etc/hostname
echo "Starting mdev"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "ifconfig eth0 192.168.1.21"
ifconfig eth0 192.168.1.21
echo "**************************************************"
echo "* *"
echo "* Linux ubuntu 2.6.32-30-generic *"
echo "* *"
echo "* arm-linux-gnueabi-gcc 4.4.5 *"
echo "* *"
echo "* 2011-04-04 *"
echo "* *"
echo "**************************************************"
/mnt/etc/profile
#/etc/profile
echo "Processing /etc/profile"
echo "set user path"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
echo "set search library path"
LD_LIBRARY_PATH=/lib:/usr/lib
echo "set PS1"
HOSTNAME=`/bin/hostname`
PS1='\u@\h:\w\$ ' #设置命令提示符为ubuntu风格
export PATH LD_LIBRARY_PATH HOSTNAME PS1
/mnt/etc/inittab:
#/etc/inittab
::sysinit:/etc/init.d/rcS
console::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
/mnt/etc/fstab:
#/etc/fstab: static file system information.
#<File system> <mount pt> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
mdev /dev ramfs defaults 0 0
none /tmp ramfs defaults 0 0
/etc/passwd
#username:password:User ID:Group ID:comment:home directory:shell
root:x:0:0:root:/root:/bin/sh
修改权限:
chmod 775 linuxrc mnt/etc/init.d/rcS mnt/etc/rc.local mnt/etc/profile
lib库复制到rootfs/lib下。
4. 往根文件系统中添加内核模块
进入内核代码
#cd …/linux
编译内核模块
#make modules ARCH=arm CROSS_COMPILE=arm-linux-
把编译好的内核模块复制到rootfs目录下(...为rootfs目录前缀)
#make modules_install ARCH=arm INSTALL_MOD_PATH=…/rootfs
5. 生成ramfs,CramFS。
$mkcramfs rootfs/ rootfs.img