制作根文件系统

来源:互联网 发布:fireworks mac版 编辑:程序博客网 时间:2024/05/21 10:37


建立环境

首先建立交叉编译环境(此博客主要介绍如何建立根文件系统,这部分就不详细介绍)

另外需要建立一个连接:

#mkdir –p /home/cpu

#cd /home/cpu

#ln –s /opt/FriendlyRAM/toolschain/4.5.1/bin/arm-linux-gcc arm-linux-gcc

注意:最后一行为工具链的路径。可根据自己主机内的实际情况设置,上面所示,只是小编的主机工具链的存放路径

 

安装图形配置的依赖工具Ncurses(此博客主要介绍如何建立根文件系统,这部分就不详细介绍)

 

图形化配置

解压busybox-1.2.21,并进入文件夹配置

#tar zxf busybox-1.22..1.tar.bz2

#cd busybox-1.22.1

#make menuconfig

 

配置为:

Busybox Setings--->

GeneralConfiguration--->(默认)

Build Options--->

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

[*] Build shared libbusybox

(/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-)Cross Compilerprefix(需要编辑)

Installation Options("make install"behavior)--->(默认)

Busybox Library Turning--->

[*] vi-style line editing commands(NEW)

[*] Fancy shell prompts(NEW)

 

InitUtilities--->(默认)

[*]init

[*]Suport reading an inittab file

[*]Run commands with leading dash with controlling tty

[*]Support running init from within an initrd (not initramfs)

Miscellaneous Utilities-->

[ ] inoice

[ ] ubiattach

[ ] ubidetach

[ ] ubimkvol

[ ] ubirmvol

[ ] ubirsvol

[ ] ubiupdatevol

 

编译busybox

配置完成后编译busybox

#make clean all

 

安装到目录:

#make install

 

busybox-1.22.1目录下生成子目录_install,其中可执行文件在bin目录下

 

构建根文件系统

建立系统根目录

#mkdir /root/rootfs

#cd /root/rootfs

#mkdir dev home proc tmp var etc lib mnt sys usr etc/rc.d

 

建立系统配置文件

注意:以下的配置文件不是在ubuntu操作系统的根目录下创建的

  1. etc/inittab文件

    说明:inittab文件是init进程的配置文件,系统启动后所访问的第一个脚本文件,后续启动的文件都由它指定。

#cd /root/ rootfs

#vimetc/inittab

 

添加如下内容:

 

::sysinit:/etc/rc.d/rc.sysinit //指定系统启动后首先执行的文件

#Example of howto put a getty on a seria line(for a terminal)

::respawn:-/bin/sh#no login(启动后进入shell环境)

#::respawn:/sbin/getty-L ttySAC0 115200 vt100 #use login

#tty::respawn:-/bin/sh

#Stuff to dowhen restarting the init porcess

: :restart:/sbin/init

#Stuff to dobefore rebooting

::ctrlaltdel:/sbin/reboot//捕捉ctrl+alt+del键,重启文件系统

::shutdown:/bin/umount-a –r //当关机时卸载所有文件系统

::shutdown:/sbin/swapoff –a

 

2etr/rc.d/rc.sysinit文件

说明:这是一个脚本文件,可以在里面添加想自动执行的命令。以下命令配置环境变量、主机名、dev目录环境、挂接/etc/fstab指定的文件系统、建立设备节点与设置IP

#vim etc/rc.d/rc.sysinit

添加如下内容

#!/bin/sh

#Set binary path

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

#Config dev enviornment

mount -t tmpfs -o size=64k,mode=0755 tmpfs/dev

mkdir -p /dev/pts

mount -t devpts devpts /dev/pts

#mount all filesystem defined in /etc/fstab

echo "#mount all....."

/bin/mount -a

echo "#Starting mdev....."

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

/sbin/mdev -s

#Set hostname

/bin/hostname "Loongson-gz"

export LAGNAME=root

#Set ip

#ifconfig eth0 192.168.3.134 up

ifconfig lo 127.0.0.1

(注意eth0ip地址可根据需要自行配置,这个地址是小编主机的ip地址)

 

3etc/fstab文件

说明:执行mount –a时挂接/etc/fstab指定的文件系统。

#vim etc/fstab

添加如下内容

 

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

tmpfs /tmp tmpfs defaults 0 0

tmpfs /mnt tmpfs defaults 0 0

tmpfs /root tmpfs defaults 0 0

tmpfs /var/log tmpfs defaults 0 0

4etc/profile文件

 说明:inittab中执行了这样一个语句::respawn:-/bin/sh

启动/bin/sh程序时会启动ash的配置信息,而它就是/etc/profilesh会把profile的所有配置全部都运行一遍,因此用户可以把自己的启动程序放在这里。

 

#vi etc/profile

添加如下内容

#!/bin/sh

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

echo"Processing /etc/profile....."

#set search librarypath

exportLD_LIBRARY_PATH=/lib:/usr/lib:/qte/lib

#set user path

exportPATH=/bin:/sbin:/usr/bin:/usr/sbin:/exe/

#Set PS1

exportPS1='[\u@\h:\w]\$'

alias ll="ls-l"

echo"Done!"

 

5修改系统配置文件权限

#chmod 755 etc/*

#chmod 755 etc/rc.d/rc.sysinit

6、拷贝Busybox文件

将安装好的Busybox文件拷贝到/root/rootfs/目录:

#cp ./busybox1.22.1/_install/*/root/rootfs –rf

 

拷贝库文件

 

#cp /opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/lib/*/root/rootfs/lib/( 路径可根据实际情况输入,此路径为小编主机工具链存在的路径)

 

创建console

#monkd /root/rootfs/dev/console c 5 1

 

至此根文件系统(目录/root/rootfs)制作完成

 

制作文件系统镜像

使用的工具为:mkyaffs2image-128M                                                                                                      

 

#mkyaffs2image/root/rootfs rootfs-yaffs2.img

#chmod 777rootfs-yaffs2.img //修改文件系统权限,防止出现无法烧写的情况

 

再用烧写文件系统的方法把文件系统烧写到开发板上(此博客主要介绍如何建立根文件系统,这部分就不详细介绍

0 0
原创粉丝点击