最小文件系统制作所需资料

一、Busybox 的设置

1、设置使用静态库

Busybox Settings--->

Build Options--->

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

2、配置交叉编译工具链前缀为 arm-none-linux-gnueabi-

Busybox Settings--->

Build Options--->

            Cross Compiler prefix --->


3、配置安装路径为 ../rootfs

Busybox Settings--->

        Installation Options --->

                BusyBox installation prefix
   

4、设置 vi 风格的命令行 ,不进行设置也可以
Busybox Library Tuning--->
[*]vi-style line editing commands
[*]Fancy shell prompts


5、设置与模块相关的
Linux Module Utilities--->
[ ]Simplified modutils
[*]insmod
[*]rmmod
[*]lsmod
[*]modprobe
[*]depmod

6、设置mdev,主要是核对一下,一般是已经选中的
Linux System Utilities--->[*]mdev
[*]Support /etc/mdev.conf
[*]Support subdirs/symlinks
[*]Support regular expressions substitutions when renaming dev
[*]Support command execution at device addition/removal

[*]Support loading of firmwares

7、编译 make


8、安装 make install


二、一步一步添加文件(注意修改文件、文件夹权限为755,以下所做操作均在刚用busybox创建的rootfs下进行)

1、添加一个典型的inittab,路径:rootfs/etc/inittab

#############以下是inittab文件内容########################

#first:run the system script file
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::ctrlaltdel:-/sbin/reboot
#umount all filesystem
::shutdown:/bin/umount -a -r
#restart init process
::restart:/sbin/init

#############inittab文件内容结束########################


2、添加rcS,路径:rootfs/etc/init.d/rcS

#############以下是rcS文件内容########################

#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin

runlevel=S
prevlevel=N

umask 022

export PATH runlevel prevlevel

mount -a

echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

/bin/hostname -F /etc/sysconfig/HOSTNAME

#ifconfig eth0 192.168.1.10

#############rcS文件内容结束########################


3、mount -a需要fstab文件支持,添加fstab,路径:rootfs/etc/fstab

#############以下是fstab文件内容########################

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /var tmpfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0

#############fstab文件内容结束#############################################


4、添加profile文件,路径:rootfs/etc/profile

#############以下是profile文件内容########################

# Ash profile
# vim: syntax=sh
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
PS1='[\u@\h \W]\# '
PATH=$PATH

HOSTNAME=`/bin/hostname`

export USER LOGNAME PS1 PATH

#############profile文件内容结束#############################################

5、实现用户登录,添加passwd和shadow,路径:rootfs/etc/passwd 和 rootfs/etc/shadow

(1)这两个文件来源:可以直接复制ubuntu系统下的passwd和shadow,然后修改。

(2)首先把inittab中的::askfirst:-/bin/sh修改为ttySAC2::sysinit:/bin/login 或 ttySAC2::respawn:/sbin/getty -L ttySAC2 115200 vt100

(3)其中ttySAC2是所使用的串口,不同开发板串口驱动名字可能不同,训为使用ttySAC2

(4)passwd文件,需要创建root目录,或者把文件中的/root改为/

#############以下是passwd文件内容########################################

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

#############passwd文件内容结束##########################################

(5)shadow文件

#############以下是shadow文件内容########################################

root::14610:0:99999:7:::

#############shadow文件内容结束##########################################


6、有可能出现的错误是:文件在windows下创建,换行时自动添加了^M之类的,导致文件明明有却提示没有存在。在ubuntu下是看不出来的,所以最好在ubuntu下所需编辑文件。


猜你喜欢

转载自blog.csdn.net/DGY1223/article/details/80504819