创建rootfs

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的代码。

创建目录:
#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

2. 创建设备节点
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值