根文件制作(一):根文件系统树 和 Initramfs文件系统的制作

 

 根文件系统树制作


首先要明白的是“什么是文件系统”,文件系统是对一个存储设备上的数据和元数据进行组织的机制。

这种机制有利于用户和操作系统的交互。

根文件系统之所以在前面加一个”根“,说明它是加载其它文件系统的”根“,既然是根的话,那么如果没有这个根,其它的文件系统也就没有办法进行加载的。它包含系统引导和使其他文件系统得以挂载(mount)所必要的文件。根文件系统包括Linux启动时所必须的目录和关键性的文件,例如Linux启动时都需要有init目录下的相关文件,在 Linux挂载分区时Linux一定会找/etc/fstab这个挂载文件等,根文件系统中还包括了许多的应用程序bin目录等,任何包括这些Linux 系统启动所必须的文件都可以成为根文件系统。

 Linux 中将一个文件系统与一个存储设备关联起来的过程称为挂载(mount)。使用 mount 命令将一个文件系统附着到当前文件系统层次结构中(根)。在执行挂装时,要提供文件系统类型、文件系统和一个挂装点。根文件系统被挂载到根目录下“/”上后,在根目录下就有根文件系统的各个目录,文件:/bin /sbin /mnt等,再将其他分区挂接到/mnt目录上,/mnt目录下就有这个分区的各个目录,文件。

 Linux根文件系统中一般有下面的几个目录:

1. /bin目录

该目录下的命令可以被root与一般账号所使用,由于这些命令在挂接其它文件系统之前就可以使用,所以/bin目录必须和根文件系统在同一个分区中。

/bin目录下常用的命令有:cat、chgrp、chmod、cp、ls、sh、kill、mount、umount、mkdir、[、test等。其中“[”命令就是test命令,我们在利用Busybox制作根文件系统时,在生成的bin目录下,可以看到一些可执行的文件,也就是可用的一些命令。

.2. /sbin 目录

该目录下存放系统命令,即只有系统管理员(俗称最高权限的root)能够使用的命令,系统命令还可以存放在/usr/sbin,/usr/local/sbin目录下,/sbin目录中存放的是基本的系统命令,它们用于启动系统和修复系统等,与/bin目录相似,在挂接其他文件系统之前就可以使用/sbin,所以/sbin目录必须和根文件系统在同一个分区中。

/sbin目录下常用的命令有:shutdown、reboot、fdisk、fsck、init等,本地用户自己安装的系统命令放在/usr/local/sbin目录下。

3. /dev目录

该目录下存放的是设备与设备接口的文件,设备文件是Linux中特有的文件类型,在Linux系统下,以文件的方式访问各种设备,即通过读写某个设备文件操作某个具体硬件。比如通过"dev/ttySAC0"文件可以操作串口0,通过"/dev/mtdblock1"可以访问MTD设备的第2个分区。比较重要的文件有/dev/null, /dev/zero, /dev/tty, /dev/lp*等。

 

 

 

 

 

.4. /etc目录

该目录下存放着系统主要的配置文件,例如人员的账号密码文件、各种服务的其实文件等。一般来说,此目录的各文件属性是可以让一般用户查阅的,但是只有root有权限修改。对于PC上的Linux系统,/etc目录下的文件和目录非常多,这些目录文件是可选的,它们依赖于系统中所拥有的应用程序,依赖于这些程序是否需要配置文件。在嵌入式系统中,这些内容可以大为精减。

.5. /lib目录

该目录下存放共享库和可加载(驱动程序),共享库用于启动系统。运行根文件系统中的可执行程序,比如:/bin /sbin 目录下的程序。

.6. home目录

系统默认的用户文件夹,它是可选的,对于每个普通用户,在/home目录下都有一个以用户名命名的子目录,里面存放用户相关的配置文件。

.7. /root目录

系统管理员(root)的主文件夹,即是根用户的目录,与此对应,普通用户的目录是/home下的某个子目录。

.8. /usr目录

/usr目录的内容可以存在另一个分区中,在系统启动后再挂接到根文件系统中的/usr目录下。里面存放的是共享、只读的程序和数据,这表明/usr目录下的内容可以在多个主机间共享,这些主要也符合FHS标准的。/usr中的文件应该是只读的,其他主机相关的,可变的文件应该保存在其他目录下,比如/var。/usr目录在嵌入式中可以精减。

.9. /var目录

与/usr目录相反,/var目录中存放可变的数据,比如spool目录(mail,news),log文件,临时文件。

 

 

 

10. /proc目录

这是一个空目录,常作为proc文件系统的挂接点,proc文件系统是个虚拟的文件系统,它没有实际的存储设备,里面的目录,文件都是由内核

临时生成的,用来表示系统的运行状态,也可以操作其中的文件控制系统。

.11. /mnt目录

用于临时挂载某个文件系统的挂接点,通常是空目录,也可以在里面创建一引起空的子目录,比如/mnt/cdram /mnt/hda1 。用来临时挂载光盘、移动存储设备等。

12. /tmp目录

用于存放临时文件,通常是空目录,一些需要生成临时文件的程序用到的/tmp目录下,所以/tmp目录必须存在并可以访问。

那我们利用Busybox制作根文件系统就是创建这上面的这些目录,和这些目录下面的各种文件。

对于嵌入式Linux系统的根文件系统来说,一般可能没有上面所列出的那么复杂,比如嵌入式系统通常都不是针对多用户的,所以/home这个目录在一般嵌入式Linux中可能就很少用到,而/boot这个目录则取决于你所使用的BootLoader是否能够重新获得内核映象从你的根文件系统在内核启动之前。一般说来,只有/bin,/dev,/etc,/lib,/proc,/var,/usr这些需要的,而其他都是可选的。

根文件系统一直以来都是所有类Unix操作系统的一个重要组成部分,也可以认为是嵌入式Linux系统区别于其他一些传统嵌入式操作系统的重要特征,它给 Linux带来了许多强大和灵活的功能,同时也带来了一些复杂性。我们需要清楚的了解根文件系统的基本结构,以及细心的选择所需要的系统库、内核模块和应用程序等,并配置好各种初始化脚本文件,以及选择合适的文件系统类型并把它放到实际的存储设备的合适位置。

对于嵌入式文件系统的制作和移植而言,它的根文件系统结构基本一样。因此,对同一个根文件系统,通过相应的工具和方法就能容易生成对应文件系统。下面介绍如何制作一个简洁的根文件系统。



制作根文件系统

制作根文件系统经常会用到根用户权限,所以需要倍加小心




tree命令可以以树形结构显示文件目录结构,它非常适合于我们给别人介绍我们的文件目录的组成框架,同时该命令使用适当的参数也可以将命令结果输出到文本文件中。安装tree命令:


 根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第1张图片

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第2张图片

 根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第3张图片

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第4张图片


Dev目录下创建设备文件

 根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第5张图片

 

Var 目录下创建符号链接文件

 根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第6张图片

 拷贝交叉编译器中的动态库到相应的目录下

查看一下自己交叉编译器的路径及*.so*文件

 

[luxibao@centos fl2440]$ ls

3rdparty  bootloader  driver  kernel  program  rootfs

[luxibao@centos fl2440]$ cd kernel/

[luxibao@centos kernel]$ ls

linux-3.0  linux-3.0.tar.bz2

[luxibao@centos kernel]$ cd linux-3.0

[luxibao@centos linux-3.0]$ ls

arch           fs       linuxrom-s3c2440.bin  README          usr

block          include  MAINTAINERS           REPORTING-BUGS  virt

COPYING        init     Makefile              samples         vmlinux

CREDITS        ipc      mm                    scripts         vmlinux.o

crypto         Kbuild   modules.builtin       security

Documentation  Kconfig  modules.order         sound

drivers        kernel   Module.symvers        System.map

firmware       lib      net                   tools

[luxibao@centos linux-3.0]$ cd /opt/buildroot-2012.08/arm920t/

[luxibao@centos arm920t]$ ls

usr

[luxibao@centos arm920t]$ find -iname "*.so*"

./usr/lib/libmpc.so.2.0.0

./usr/lib/libgmp.so.10.0.5

./usr/lib/libltdl.so.7

./usr/lib/libltdl.so.7.2.2

./usr/lib/libmpfr.so.4.1.1

./usr/lib/libmpc.so.2

./usr/lib/libmpfr.so.4

./usr/lib/libmpfr.so

./usr/lib/libmpc.so

./usr/lib/libgmp.so.10

./usr/lib/libltdl.so

./usr/lib/libgmp.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflap.so.0

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so.6.0.14-gdb.py

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so.6.0.14

省略N行..........................

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libdl.so.0

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libpthread.so.0

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libgcc_s.so.1

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libuClibc-0.9.33.2.so

 

 

[luxibao@centos arm920t]$ cd

[luxibao@centos ~]$ cat /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Thu Jul 14 00:24:28 2016

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=6f9a4081-5b62-41a8-91a2-4e0193a38eb2 /                       ext4    defaults        1 1

UUID=ca1f139e-1401-4e65-bd1f-9e298287daaf swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

拷贝交叉编译器中的动态库到相应的目录下

[luxibao@centos rootfs]$ cd rootfs/

[luxibao@centos rootfs]$ ls

apps  bin  data  dev  etc  info  lib  mnt  proc  root  sbin  sys  tmp  usr  var

[luxibao@centos rootfs]$ ls lib/

modules

[luxibao@centos rootfs]$ cp -af /opt/buildroot-2012.08/arm920t/usr/lib/lib*.so* lib/

[luxibao@centos rootfs]$ ls lib/

libgmp.so         libltdl.so        libmpc.so        libmpfr.so        modules

libgmp.so.10      libltdl.so.7      libmpc.so.2      libmpfr.so.4

libgmp.so.10.0.5  libltdl.so.7.2.2  libmpc.so.2.0.0  libmpfr.so.4.1.1

[luxibao@centos rootfs]$ cd lib/

[luxibao@centos lib]$ ll

总用量 1024

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:02 libgmp.so -> libgmp.so.10.0.5

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:02 libgmp.so.10 -> libgmp.so.10.0.5

-rwxr-xr-x. 1 luxibao luxibao 488709 7月  14 23:02 libgmp.so.10.0.5

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:03 libltdl.so -> libltdl.so.7.2.2

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:03 libltdl.so.7 -> libltdl.so.7.2.2

-rwxr-xr-x. 1 luxibao luxibao  46306 7月  14 23:03 libltdl.so.7.2.2

lrwxrwxrwx. 1 luxibao luxibao     15 7月  14 23:04 libmpc.so -> libmpc.so.2.0.0

lrwxrwxrwx. 1 luxibao luxibao     15 7月  14 23:04 libmpc.so.2 -> libmpc.so.2.0.0

-rwxr-xr-x. 1 luxibao luxibao  95963 7月  14 23:04 libmpc.so.2.0.0

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:02 libmpfr.so -> libmpfr.so.4.1.1

lrwxrwxrwx. 1 luxibao luxibao     16 7月  14 23:02 libmpfr.so.4 -> libmpfr.so.4.1.1

-rwxr-xr-x. 1 luxibao luxibao 404434 7月  14 23:02 libmpfr.so.4.1.1

drwxrwxr-x. 3 luxibao luxibao   4096 7月  18 07:47 modules

Etc 目录下创建一些文件

创建inittab文件

[luxibao@centos rootfs]$ cd etc/

[luxibao@centos etc]$ ls

dropbear  init.d

[luxibao@centos etc]$ vim inittab

 

# /etc/inittab                                                                       

#

# Copyright (C) 2011 fulinux

#

# Note: BusyBox init doesn't support runlevels.  The runlevels field is

# completely ignored by BusyBox init. If you want runlevels, use sysvinit.

#

# Format for each entry: :::

#

# id        == tty to run on, or empty for /dev/console.

#              If specified, then /dev/$id device must exist

# runlevels == ignored, busybox doesn't support it

# action    == one of sysinit, respawn, askfirst, wait, and once

# process   == program to run

 

# Startup the system

# mount all the file systems specified in /etc/fstab

::sysinit:/bin/mount -a

 

#Use mdev as hotplug to auto mount USB storage or SD card

::sysinit:/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug

 

#Use mdev to auto generate the device node in /dev path

::sysinit:/sbin/mdev -s

 

#make shm, pts support

::sysinit:/bin/mkdir -p /dev/pts

::sysinit:/bin/mkdir -p /dev/shm

::sysinit:/bin/mount -t devpts devpts /dev/pts

 

#Mount our apps/info partition

null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock6 /apps

null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock7 /info

 

#Set hostname

null::sysinit:/bin/hostname -F /etc/hostname

 

#Enable console logon

null::respawn:/sbin/getty -L ttyS0 115200 vt100

 

# now run any rc scripts

null::wait:/etc/init.d/rcS

 

# system daemon

null::respawn:/sbin/syslogd -n

null::respawn:/sbin/klogd -n

 

# Stuff to do before rebooting

null::shutdown:/bin/umount /apps

null::shutdown:/bin/umount /info

null::shutdown:/bin/killall klogd

null::shutdown:/bin/killall syslogd

null::shutdown:/bin/umount -a -r

#null::shutdown:/sbin/swapoff -a

"inittab" [] 54L, 1768C已写入  

创建/etc/init.d/rcS脚本

[luxibao@centos etc]$ vim init.d/rcS

 

#!/bin/sh

 

# Copyright (C) 2011 fulinux

# Start all init scripts in /etc/init.d

# executing them in numerical order.

#

 

for i in /etc/init.d/S??* ; do

            $i

Done

 

 

"init.d/rcS" [] 10L, 218C已写入

配置网卡的启动脚本

[luxibao@centos etc]$ vim  init.d/S01_network

 

#!/bin/sh

 

ifconfig eth0 192.168.1.111 netmask 255.255.255.0 up

 

 

 

"init.d/S01_network" [] 3L, 64C已写入

 

创建支持/apps/etc目录下的启动脚本

[luxibao@centos etc]$ vim init.d/S99_rcsApp

 

#!/bin/sh

 

# Copyright (C) 2011 fulinux

#

# Start all init scripts in /apps/etc/init.d

# executing them in numerical order.

#

if (test -d /apps/etc/init.d)

    then

    for i in /apps/etc/init.d/S??* ; do

    $i

    done

Fi

 

 

"init.d/S99_rcsApp" [] 13L, 244C已写入

 

修改init.d目录下的文件权限

[luxibao@centos etc]$ chmod 777 init.d/*

[luxibao@centos etc]$ ll init.d/

总用量 12

-rwxrwxrwx. 1 luxibao luxibao 218 7月  18 09:49 rcS

-rwxrwxrwx. 1 luxibao luxibao  64 7月  18 09:50 S01_network

-rwxrwxrwx. 1 luxibao luxibao 244 7月  18 09:53 S99_rcsApp

 

创建fstab文件

 

[luxibao@centos etc]$ vim fstab

 

# /etc/fstab: static file system information.

# Copyright (C) 2011 fulinux

#

#                 

#devpts          /dev/pts       devpts   defaults          0      0

#/dev/root       /              ext2     rw,noauto         0      1

proc            /proc          proc     defaults          0      0

tmpfs           /tmp          tmpfs    defaults          0      0

tmpfs           /dev          tmpfs    defaults          0      0

sysfs           /sys           sysfs    defaults          0      0

 

 

"fstab" [] 10L, 570C已写入

创建hostname,hosts,TZ文件

[luxibao@centos etc]$ echo "root" > hostname

[luxibao@centos etc]$ echo "127.0.0.1      localhost" >> hosts

[luxibao@centos etc]$ echo "MST7MDT" >> TZ

[luxibao@centos etc]$ echo "Copyright (C) 2011 fulinux" >> issue    #系统登录时的提示信息

 

创建profile文件

[luxibao@centos etc]$ vim profile

 

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

 

export PATH=\

/bin:\

/sbin:\

/usr/bin:\

/usr/sbin:\

/usr/local/bin:\

/apps/bin:\

/apps/tools:\

/apps/tslib/bin\

 

# If running interactively, then:

if [ "$PS1" ]; then

 

   if [ "$BASH" ]; then

        export PS1="[\u@\h \W]\\$ "

        alias ll='/bin/ls --color=tty -laFh'

        alias ls='/bin/ls --color=tty -F'

        export

LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;

    32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.de

b=0

    1;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;

35

    :*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:

*.d

    l=01;35:*.xcf=01;35:*.xwd=01;35:';

        else

          if [ "`id -u`" -eq 0 ]; then

            export PS1='>: '

          else

            export PS1='>: '

          fi

         fi

      # System Setting

          set -o vi

          alias  ll='ls -l'

          export USER=`id -un

          export LOGNAME=$USER

          export HOSTNAME=`/bin/hostname`

          export HISTSIZE=1000

          export HISTFILESIZE=1000

          export PAGER='/bin/more '

          export EDITOR='/bin/vi'

          export INPUTRC=/etc/inputrc

          export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile

          export VAR1=

          export VAR2=

          export VAR3=

          export VAR4=

          export VAR5=

          export LD_LIBRARY_PATH=/lib:/usr/lib/

# QT Extendded 4.4.3 Setting

    export QTDIR=/apps/qt-extended-4.4.3

    export QWS_MOUSE_PROTO='TSLIB:/dev/event0'

    export QWS_DISPLAY='LinuxFB:/dev/fb0'

    export QWS_DISPLAY='LinuxFB:mmWidth240:mmHeight320:0'

    export QWS_SIZE='240x320'

    export QT_PLUGIN_PATH=$QTDIR/plugins/

    export QT_QWS_FONTDIR=$QTDIR/lib/fonts

    export PATH=$QTDIR/bin:$PATH

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib

# Touch Scree tslib Setting

    export TSLIB_ROOT=/apps/tslib

    export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf

    export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal

    export TSLIB_TSDEVICE=/dev/event0

    export TSLIB_CONSOLEDEVICE=none

    export TSLIB_FBDEVICE=/dev/fb0

fi;

 

 

"profile" [] 71L, 2372C已写入  

创建指定一些协议所使用的端口号文件protocols

[luxibao@centos etc]$ vim protocols

 

# /etc/protocols:

# # $Id: protocols,v 1.1.1.1 2001/09/12 19:03:24 andersee Exp $

# #

# # Internet (IP) protocols

# #

# #       from: @(#)protocols     5.1 (Berkeley) 4/17/89

# #

# #       Updated for NetBSD based on RFC 1340, Assigned Numbers (July 1992).

#

# ip      0       IP              # internet protocol, pseudo protocol number

# icmp    1       ICMP            # internet control message protocol

# igmp    2       IGMP            # Internet Group Management

# ggp     3       GGP             # gateway-gateway protocol

# ipencap 4       IP-ENCAP        # IP encapsulated in IP (officially ``IP'')

# st      5       ST              # ST datagram mode

# tcp     6       TCP             # transmission control protocol

# egp     8       EGP             # exterior gateway protocol

# pup     12      PUP             # PARC universal packet protocol

# udp     17      UDP             # user datagram protocol

# hmp     20      HMP             # host monitoring protocol

# xns-idp 22      XNS-IDP         # Xerox NS IDP

# rdp     27      RDP             # "reliable datagram" protocol

# iso-tp4 29      ISO-TP4         # ISO Transport Protocol class 4

# xtp     36      XTP             # Xpress Tranfer Protocol

# ddp     37      DDP             # Datagram Delivery Protocol

# idpr-cmtp       39      IDPR-CMTP       # IDPR Control Message Transport

# rspf    73      RSPF            #Radio Shortest Path First.

# vmtp    81      VMTP            # Versatile Message Transport

# ospf    89      OSPFIGP         # Open Shortest Path First IGP

# ipip    94      IPIP            # Yet Another IP encapsulation

# encap   98      ENCAP           # Yet Another IP encapsulation

~

~

~

~

"protocols" [] 31L, 1676C已写入

 

创建mdev.conf文件

mdev会在/etc目录下找mdev的配置文件: mdev.conf. 如果该文件不存在,那么在执行mdev –s这个命令时,

会提示找不到mdev.conf,这时我们可以建一个空的mdev.conf文件解决这个问题。下面创建使用mdev自动挂载u盘和SD卡的配置/etc/mdev.conf

 

[luxibao@centos etc]$ vim mdev.conf

 

sd[a-z][0-9]      0:0 0777        @(mount /dev/$MDEV /mnt/usb)

sd[a-z]           0:0 0777        $(umount /mnt/usb)

ub[a-z][0-9]      0:0 0777        @(mount /dev/$MDEV /mnt/usb)

ub[a-z]           0:0 0777        $(umount /mnt/usb)

mmcblk[0-9]p[0-9] 0:0 0777        @(mount /dev/$MDEV /mnt/sdc)

mmcblk[0-9]       0:0 0777        $(umount /mnt/sdc)

 

 

"mdev.conf" [] 6L, 348C已写入

 

 

创建用户组group文件

[luxibao@centos etc]$ vim group

 

root:x:0:root

 

 

"group" [] 1L, 14C已写入

 

它的格式如下:

 

groupname:password:gid:members

 

第一个字段为用户组名称

第二个字段为用户组密码,当为x时密码是映射到/etc/gshadow中的,是非逆的

第三个字段为GID,及组号,为正整数或0,0被付于了root用户组;系统通常会预留一些较靠前的GID给系统虚拟用户之用,每个系统预留的GID都不同,Fedora预留了500个,所以我们添加新用户组时是从500开始的。GID的范围由/etc/login.defs中的GID_MIN和GID_MAX决定

第四个字段为用户列表,每个用户间用逗号分隔

 

这里的password代表组口令,很少用到。它可使原先不在这个群组中的用户可以通过newgrp命令暂时继承该组的权限,使用 newgrp命令时会新开一个shell。口令的加密方式和passwd文件中的口令一样,所以如果需设置组口令,要用passwd程序虚设一个用户,再把该用户password节中的加密口令拷贝到/etc/group文件中。members列代表组成员,我们可把需加入该组的用户以逗号分隔添加到这里即可。同一组的成员可继承该组所拥有的权限。

 

创建用户passwd文件

[luxibao@centos etc]$ vim passwd

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

"passwd" [] 1L, 26C已写入

 

它的格式如下:

username:password:uid:gid:gecos:homedir:shell

 

第一个字段为登录名

第二个字段为口令,一般被映射到shadow文件中

第三个字段为UID

第四个字段为GID

第五个字段为用户名全称,gecos是通用电子计算机操作系统的缩写,是Bell实验室中的一台大型主机。

第六个字段为用户根目录

第七个字段为用户所用SHELL的类型

 

Unix系统最初是用明文保存密码的,后来由于安全的考虑,采用crypt()算法加密密码并存放在/etc/passwd文件。现在,由于计算机处理能力的提高,使密码破解变得越来越容易。/etc/passwd文件是所有合法用户都可访问的,大家都可互相看到密码的加密字符串,这给系统带来很大的安全威胁。现代的Unix系统使用影子密码系统,它把密码从/etc/pa sswd文件中分离出来,真正的密码保存在/etc/shadow文件中,shadow文件只能由超级用户访问。这样入侵者就不能获得加密密码串,用于破解。使用shadow密码文件后,/etc/passwd文件中所有帐户的password域的内容为"x",如果password域的内容为"*",则该帐号被停用。使用passwd这个程序可修改用户的密。

 

 

创建密码映射shadow文件

这里我们设置为不用密码登陆,将password格式的内容清空:

 

[luxibao@centos rootfs]$ vim etc/shadow

 

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

~

~

~

"etc/shadow" [] 1L, 21C已写入

 

 

在文件系统中安装busybox

[luxibao@centos rootfs]$ cd

[luxibao@centos ~]$ ls

fl2440  公共的  模板  视频  图片  文档  下载  音乐  桌面

[luxibao@centos ~]$ cd fl2440/

[luxibao@centos fl2440]$ ls

3rdparty  bootloader  driver  kernel  program  rootfs

[luxibao@centos fl2440]$ cd 3rdparty/

[luxibao@centos 3rdparty]$ ls

[luxibao@centos 3rdparty]$ rz

rz waiting to receive.

Starting zmodem transfer.  Press Ctrl+C to cancel.

Transferring busybox-1.20.2.tar.bz2...

  100%    2135 KB 2135 KB/s 00:00:01       0 Errors

 

?[luxibao@centos 3rdparty]$ ls

busybox-1.20.2.tar.bz2

[luxibao@centos 3rdparty]$ tar xjf busybox-1.20.2.tar.bz2

[luxibao@centos 3rdparty]$ ls

busybox-1.20.2  busybox-1.20.2.tar.bz2

[luxibao@centos 3rdparty]$ cd busybox-1.20.2

 

[luxibao@centos busybox-1.20.2]$ vim Makefile

 

#修改CROSS_COMPILER为:

CROSS_COMPILE ?= /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-

 

[luxibao@centos6 busybox-1.20.2]$ ls ../../rootfs/rootfs/

apps  bin  data  dev  etc  info  lib  mnt  proc  root  sbin  sys  tmp  usr  var

 

[luxibao@centos6 busybox-1.20.2]$ make menuconfig

#选择:

  Busybox Settings  --->

       General Configuration  --->

             [*] Don't use /usr

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

             What kind of applet links to install (as soft-links)  --->

(home/luxibao/fl2440/rootfs/rootfs/) BusyBox installation prefix

 

#其他选项结合和自己的需求定制

 

[luxibao@centos6 busybox-1.20.2]$ make

 

[luxibao@centos busybox-1.20.2]$  file busybox

busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped

[luxibao@centos busybox-1.20.2]$ sudo make install

 

 /home/luxibao/fl2440/rootfs/rootfs//bin/[ -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/[[ -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/add-shell -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/addgroup -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/adduser -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/arping -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/ash -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/awk -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/base64 -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/basename -> busybox

  /home/luxibao/fl2440/rootfs/rootfs//bin/beep -> busybox

省略N行............................

  /home/luxibao/fl2440/rootfs/rootfs//sbin/udhcpd -> ../bin/busybox

  /home/luxibao/fl2440/rootfs/rootfs//sbin/vconfig -> ../bin/busybox

  /home/luxibao/fl2440/rootfs/rootfs//sbin/watchdog -> ../bin/busybox

  /home/luxibao/fl2440/rootfs/rootfs//sbin/zcip -> ../bin/busybox

 

 

--------------------------------------------------

You will probably need to make your busybox binary

setuid root to ensure all configured applets will

work properly.

--------------------------------------------------

 

[luxibao@centos busybox-1.20.2]$ ls

applets                 Config.in      include     Makefile.custom  scripts

applets_sh              configs        init        Makefile.flags   selinux

arch                    console-tools  _install    Makefile.help    shell

archival                coreutils      INSTALL     miscutils        sysklogd

AUTHORS                 debianutils    libbb       modutils         testsuite

busybox                 docs           libpwdgrp   networking       TODO

busybox.links           e2fsprogs      LICENSE     printutils       TODO_unicode

busybox_unstripped      editors        loginutils  procps           util-linux

busybox_unstripped.map  examples       mailutils   README

busybox_unstripped.out  findutils      Makefile    runit

[luxibao@centos busybox-1.20.2]$ cd ../

[luxibao@centos 3rdparty]$ cd ../

[luxibao@centos fl2440]$ cd rootfs

[luxibao@centos rootfs]$ cd rootfs/

[luxibao@centos rootfs]$ ls

apps  data  etc   init  linuxrc  proc  sbin  tmp  var

bin   dev   info  lib   mnt      root  sys   usr

 

移植dropbear

首先编译生成PC版的,在制作密钥时用到

[luxibao@centos ~]$ wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.53.1.tar.bz2

 

[luxibao@centos ~]$ tar -xjf dropbear-0.53.1.tar.bz2

 

[luxibao@centos ~]$ cd dropbear-0.53.1

[luxibao@centos dropbear-0.53.1]$./configure && make

 

生成的文件:

    dropbear: ssh2 server

    dropbearkey: 密钥生成器

    dropbearconvert: 可以转换openssh的密钥

dbclient: ssh2 client

 

[luxibao@centos dropbear-0.53.1]$ ./dropbearkey -t rsa -f /home/luxibao/fl2440/rootfs/rootfs/etc/dropbear/dropbear_rsa_host_key

Will output 1024 bit rsa secret key to '/home/luxibao/fl2440/rootfs/rootfs/etc/dropbear/dropbear_rsa_host_key'

Generating key, this may take a while...

Public key portion is:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgkz1a393mku4JXzyW4T014jxqQfcnuFAApQTEwRhDle3gTKNFORfoS3rJUc0ENjwwxu4VyDzsgAjrILGuP9t0tVn9oM+O0j10OyNTRY9sDXzupBguxIFruG39uUU8VSxHm+/w0j6hqGlxzwI7PEV/nlU2iv2maoZuhDceRhrM5ny1r8= [email protected]

Fingerprint: md5 6b:25:d5:fa:b7:10:3b:2b:46:e2:c1:cf:59:28:f7:a9

 

[luxibao@centos dropbear-0.53.1]$ ./dropbearkey -t dss -f /home/luxibao/fl2440/rootfs/rootfs/etc/dropbear/dropbear_dss_host_key

Will output 1024 bit dss secret key to '/home/luxibao/fl2440/rootfs/rootfs/etc/dropbear/dropbear_dss_host_key'

Generating key, this may take a while...

Public key portion is:

ssh-dss AAAAB3NzaC1kc3MAAACBAJG3OxxJZ1J8GMHvJrSPPHkoauydPmpBGsBscQWiVfC8d4lURbdOFDfh2rQe6ZEjizjoV+OOKhg3S8SWOp0R55Am0cwpeB8XJaV3iWZwldx/JrcqRVZDjXIrryEtrFTSpHkkSNsivUTRnuzcakq+/Dxhw5rC/ahrs5cCvabgQNbfAAAAFQDHmVLiFI05ZA6rcTTOJuZv3OCTawAAAIBNL2GAnd7eaigPrgUqAKkQ4jUhDywk86+RHTSfls6V5hlOtWF5g8mB6USqbO7fBd1P3ckD9SpE8XCD2lkmYBevJtNr/p+4Cuz57NlS4sN9cy9RVdDbuAaUdXV7FffenR7rhl0KSeoXtMx0QYOcHKHnifN9A+j1seWBK4AsDzAcXQAAAIBKVUH0erG2LMhDgK6maxDkeHkJe6LX8aT5uQSV9bv1ftQst0BD0nChe+00ZyldS8m1qu+aBbtEoPpmZ9UnQiu5aE+jurF4wzflLqi+brb09McZZqGtKFIlLs4mibv11c3T0dQAIapE90Y32i29I/p6ULE7KHUy++U4pYXCXJ61YQ== [email protected]

Fingerprint: md5 cd:eb:06:06:7d:6c:60:90:a3:23:60:a1:6a:09:f8:31

 

[luxibao@centos dropbear-0.53.1]$ chmod 666 /home/luxibao/fl2440/rootfs/rootfs/etc/dropbear/dropbear_*

 

 

编译ARM版本的

 

[luxibao@centos dropbear-0.53.1]$ make  distclean

 

[luxibao@centos dropbear-0.53.1]$ ./configure CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc --build=i686 --host=arm-linux --disable-zlib

 

[luxibao@centos dropbear-0.53.1]$ make

 

[luxibao@centos dropbear-0.53.1]$ file dropbear

dropbear: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

[luxibao@centos dropbear-0.53.1]$  file dbclient

dbclient: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

[[email protected]]$  /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip dropbear

[luxibao@centos dropbear-0.53.1]$ mv dbclient ssh

[luxibao@centos dropbear-0.53.1]$ /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip ssh

[luxibao@centos dropbear-0.53.1]$ cp dropbear ssh /home/luxibao/fl2440/rootfs/rootfs/usr/sbin/

 

在文件系统中创建启动脚本

[luxibao@centos rootfs]$ vim etc/init.d/S04_dropbear

 

#!/bin/sh

/usr/sbin/dropbear

[luxibao@centos rootfs]$ chmod 777 etc/init.d/S04_dropbear

[luxibao@centos rootfs]$ ls

apps  bin  data  dev  etc  info  init  lib  linuxrc  mnt  proc  root  sbin  sys  tmp  usr  var

 

* 在开发板中移植上面制作的根文件系统后的截图如下所示:

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第7张图片

 

对根文件系统进行修改

由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在上面制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。

 

 

[luxibao@centos6 rootfs]$ ln -s bin/busybox init

[luxibao@centos rootfs]$ ll

总用量 60

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 apps

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 12:15 bin

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 data

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:55 dev

drwxrwxr-x. 4 luxibao luxibao 4096 7月  18 10:31 etc

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 info

lrwxrwxrwx. 1 luxibao luxibao   11 7月  18 11:57 init -> bin/busybox

drwxrwxr-x. 3 luxibao luxibao 4096 7月  18 09:21 lib

lrwxrwxrwx. 1 root    root      11 7月  18 12:15 linuxrc -> bin/busybox

drwxrwxr-x. 6 luxibao luxibao 4096 7月  18 07:47 mnt

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 proc

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 root

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 12:15 sbin

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 sys

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 07:47 tmp

drwxrwxr-x. 6 luxibao luxibao 4096 7月  18 07:47 usr

drwxrwxr-x. 2 luxibao luxibao 4096 7月  18 08:04 var

 

添加内核对initramfs的支持

[luxibao@centos fl2440]$ ls

3rdparty  bootloader  driver  kernel  program  rootfs

[luxibao@centos fl2440]$ cd kernel/

[luxibao@centos kernel]$ ls

linux-3.0  linux-3.0.tar.bz2

[luxibao@centos kernel]$ cd linux-3.0

[luxibao@centos linux-3.0]$ export TERM=vt100

[luxibao@centos linux-3.0]$ make menuconfig

 

。 。 。 。 。 。

General setup  --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/home/luxibao/fl2440/rootfs/rootfs) Initramfs source file(s)   #输入根文件系统的所在目录 

 。 。 。 。 。

 

 

[luxibao@centos linux-3.0]$ ls

arch           drivers   Kbuild                Makefile         README          System.map

block          firmware  Kconfig               mm               REPORTING-BUGS  tools

COPYING        fs        kernel                modules.builtin  samples         usr

CREDITS        include   lib                   modules.order    scripts         virt

crypto         init      linuxrom-s3c2440.bin  Module.symvers   security        vmlinux

Documentation  ipc       MAINTAINERS           net              sound           vmlinux.o

 

[luxibao@centos linux-3.0]$  du -h  linuxrom-s3c2440.bin

6.7M    linuxrom-s3c2440.bin

[luxibao@centos linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/

 

制作映像文件

添加ubootinitramfs支持

Uboot源码基本上不做修改。

下面对uboot进行修改。

 

U-Boot 2010.09 (Jul 17 2016 - 19:56:41)

 

DRAM:  64 MiB

NAND:  256 MiB

In:    serial

Out:   serial

Err:   serial

Net:   dm9000

Hit any key to stop autoboot:  0

[fl2440@lingyun]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 8000000;nand write 30008000 100000 800000'

[fl2440@lingyun]# set bootcmd_initramdisk 'nand read 30008000 100000 800000;bootm 30008000'

[fl2440@lingyun]#  set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'

[fl2440@lingyun]# set bootcmd 'run bootcmd_initramdisk'

[fl2440@lingyun]#  save

Saving Environment to NAND...

Erasing Nand...

Erasing at 0x60000 -- 100% complete.

Writing to Nand... done

[fl2440@lingyun]# pri

bbl=tftp 30008000 u-boot-s3c2440.bin;nand erase 0 100000;nand write 30008000 0 40000

blx=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 F00000;nand write 30008000 100000 F00000

tb=tftp 30008000 linuxrom-s3c2440.bin; bootm 30008000

bootdelay=2

baudrate=115200

ethaddr=08:00:3e:26:0a:51

ipaddr=192.168.1.168

serverip=192.168.1.2

netmask=255.255.255.0

ethact=dm9000

stdin=serial

stdout=serial

stderr=serial

bkr=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 8000000;nand write 30008000 100000 800000

bootcmd_initramdisk=nand read 30008000 100000 800000;bootm 30008000

bootargs=console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7

bootcmd=run bootcmd_initramdisk

 

Environment size: 675/131068 bytes

[fl2440@lingyun]# run bkr

dm9000 i/o: 0x20000300, id: 0x90000a46

DM9000: running in 16 bit mode

MAC: 08:00:3e:26:0a:51

could not establish link

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.2; our IP address is 192.168.1.168

Filename 'linuxrom-s3c2440.bin'.

Load address: 0x30008000

Loading: #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #####################

done

Bytes transferred = 6975480 (6a6ff8 hex)

 

NAND erase: device 0 offset 0x100000, size 0x8000000

Skipping bad block at  0x00d20000                                          

Skipping bad block at  0x03360000                                          

Erasing at 0x80e0000 -- 100% complete.

OK

 

NAND write: device 0 offset 0x100000, size 0x800000

 8388608 bytes written: OK

 

启动引导

[fl2440@lingyun]#  boot

 

NAND read: device 0 offset 0x100000, size 0x800000

 8388608 bytes read: OK

## Booting kernel from Legacy Image at 30008000 ...

   Image Name:   Linux Kernel

   Created:      2016-07-18   6:55:33 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    6975416 Bytes = 6.7 MiB

   Load Address: 30008040

   Entry Point:  30008040

   Verifying Checksum ... OK

   Loading Kernel Image ... OK

OK

 

Starting kernel ...

 

Uncompressing Linux... done, booting the kernel.

Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #3 Mon Jul 18 14:55:10 CST 2016

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177

CPU: VIVT data cache, VIVT instruction cache

Machine: SMDK2440

Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C24XX Clocks, Copyright 2004 Simtec Electronics

S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256

Kernel command line: console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7

PID hash table entries: 256 (order: -2, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory: 64MB = 64MB total

Memory: 46268k/46268k available, 19268k reserved, 0K highmem

Virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)

    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)

    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)

    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)

    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)

    modules : 0xbf000000 - 0xc0000000   (  16 MB)

      .init : 0xc0008000 - 0xc0e0e000   (14360 kB)

      .text : 0xc0e0e000 - 0xc11e1000   (3916 kB)

      .data : 0xc11e2000 - 0xc1204800   ( 138 kB)

       .bss : 0xc1204824 - 0xc1234a60   ( 193 kB)

SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

NR_IRQS:85

irq: clearing pending ext status 00080800

irq: clearing pending ext status 00000800

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttyS0] enabled

Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

gpiochip_add: gpios 288..303 (GPIOK) failed to register

gpiochip_add: gpios 320..334 (GPIOL) failed to register

gpiochip_add: gpios 352..353 (GPIOM) failed to register

NET: Registered protocol family 16

S3C Power Management, Copyright 2004 Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C244X: Clock Support, DVS off

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

s3c-i2c s3c2440-i2c: slave address 0x10

s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz

s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter

Advanced Linux Sound Architecture Driver Version 1.0.24.

Bluetooth: Core ver 2.16

NET: Registered protocol family 31

Bluetooth: HCI device and connection manager initialized

Bluetooth: HCI socket layer initialized

cfg80211: Calling CRDA to update world regulatory domain

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

UDP hash table entries: 256 (order: 0, 4096 bytes)

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

NET: Registered protocol family 1

RPC: Registered named UNIX socket transport module.

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 90

Console: switching to colour frame buffer device 60x53

fb0: s3c2410fb frame buffer device

s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440

s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440

s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns

s3c24xx-nand s3c2440-nand: NAND soft ECC

NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)

Scanning device for bad blocks

Bad eraseblock 105 at 0x000000d20000

Bad eraseblock 411 at 0x000003360000

Bad eraseblock 1048 at 0x000008300000

Bad eraseblock 1392 at 0x00000ae00000

Bad eraseblock 1789 at 0x00000dfa0000

Creating 6 MTD partitions on "NAND":

0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"

0x000000100000-0x000001000000 : "mtdblock1 kernel 15MB"

0x000001000000-0x000005000000 : "mtdblock2 rootfs 64MB"

0x000005000000-0x00000a000000 : "mtdblock3 apps 80MB"

0x00000a000000-0x00000d000000 : "mtdblock4 data 48MB"

0x00000d000000-0x000010000000 : "mtdblock5 backup 48MB"

dm9000 Ethernet Driver, V1.31

ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver

s3c2410-ohci s3c2410-ohci: S3C24XX OHCI

s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1

s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

s3c2410_udc: debugfs dir creation failed -19

mousedev: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

i2c /dev entries driver

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

sdhci: Secure Digital Host Controller Interface driver

sdhci: Copyright(c) Pierre Ossman

usbcore: registered new interface driver usbhid

usbhid: USB HID core driver

ALSA device list:

  No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

lib80211: common routines for IEEE802.11 drivers

Registering the dns_resolver key type

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

Warning: unable to open an initial console.

Freeing init memory: 14360K

usb 1-1: new full speed USB device number 2 using s3c2410-ohci

usb 1-1: device descriptor read/64, error -62

usb 1-1: device descriptor read/64, error -62

usb 1-1: new full speed USB device number 3 using s3c2410-ohci

usb 1-1: device descriptor read/64, error -62

usb 1-1: device descriptor read/64, error -62

usb 1-1: new full speed USB device number 4 using s3c2410-ohci

usb 1-1: device not accepting address 4, error -62

usb 1-1: new full speed USB device number 5 using s3c2410-ohci

usb 1-1: device not accepting address 5, error -62

hub 1-0:1.0: unable to enumerate USB device on port 1

 

Copyright (C) 2016 Reagan

root login: root

Password:

>: ls

apps     data     etc      init     linuxrc  proc     sbin     tmp      var

bin      dev      info     lib      mnt      root     sys      usr

 

这样initramfs文件系统就制作成功

 

 

 

initramfs文件系统制作过程中遇到的问题和解决方法:

 

 

1.拷贝交叉编译器中的动态库时路径出错,查看一下自己交叉编译器的*.so*文件是查找不完全:

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第8张图片

 

 

解决:找到正确路径,用find -iname "*.so*"命令查找可以查找完全

[luxibao@centos fl2440]$ ls

3rdparty  bootloader  driver  kernel  program  rootfs

[luxibao@centos fl2440]$ cd kernel/

[luxibao@centos kernel]$ ls

linux-3.0  linux-3.0.tar.bz2

[luxibao@centos kernel]$ cd linux-3.0

[luxibao@centos linux-3.0]$ ls

arch           fs       linuxrom-s3c2440.bin  README          usr

block          include  MAINTAINERS           REPORTING-BUGS  virt

COPYING        init     Makefile              samples         vmlinux

CREDITS        ipc      mm                    scripts         vmlinux.o

crypto         Kbuild   modules.builtin       security

Documentation  Kconfig  modules.order         sound

drivers        kernel   Module.symvers        System.map

firmware       lib      net                   tools

[luxibao@centos linux-3.0]$ cd /opt/buildroot-2012.08/arm920t/

[luxibao@centos arm920t]$ ls

usr

[luxibao@centos arm920t]$ find -iname "*.so*"

./usr/lib/libmpc.so.2.0.0

./usr/lib/libgmp.so.10.0.5

./usr/lib/libltdl.so.7

./usr/lib/libltdl.so.7.2.2

./usr/lib/libmpfr.so.4.1.1

./usr/lib/libmpc.so.2

./usr/lib/libmpfr.so.4

./usr/lib/libmpfr.so

./usr/lib/libmpc.so

./usr/lib/libgmp.so.10

./usr/lib/libltdl.so

./usr/lib/libgmp.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflap.so.0

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so.6.0.14-gdb.py

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libstdc++.so.6.0.14

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflap.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libgcc_s.so

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflapth.so.0.0.0

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflap.so.0.0.0

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflapth.so.0

./usr/arm-unknown-linux-uclibcgnueabi/lib/libmudflapth.so

省略N行.....................

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libdl.so.0

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libpthread.so.0

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libgcc_s.so.1

./usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libuClibc-0.9.33.2.so

 

2.没有转换目录。

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第9张图片

 

解决:  将[luxibao@centos etc]$ vim etc/shadow

     改为[luxibao@centos rootfs]$ vim etc/shadow

 

3. [luxibao@centos busybox-1.20.2]$ ls ../../rootfs/rootfs/

apps  bin  data  dev  etc  info  lib  mnt  proc  root  sbin  sys  tmp  usr  var

没有init和linuxrc 文件

解决:3.1   [luxibao@centos ~]$  ln -s bin/busybox init

3.2

#选择:

  Busybox Settings  --->

       General Configuration  --->

             [*] Don't use /usr

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

             What kind of applet links to install (as soft-links)  --->

(home/luxibao/fl2440/rootfs/rootfs/) BusyBox installation prefix(改对路径)


4.[luxibao@centos busybox-1.20.2]$ ln -s bin/busybox init   路径弄错。

根文件制作(一):根文件系统树 和 Initramfs文件系统的制作_第10张图片

 

解决:用sudo权限删除掉busybox-1.20.2文件夹 重新做busybox-1.20.2.tar.bz2解压和安装busybox

5.[luxibao@centos dropbear-0.53.1]$ /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip ssh

/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip: 'ssh': No such file

 

解决:[luxibao@centos dropbear-0.53.1]$ mv dbclient ssh

[luxibao@centos drop


 

解决:  将[luxibao@centos etc]$ vim etc/shadow

     改为[luxibao@centos rootfs]$ vim etc/shadow

 

3. [luxibao@centos busybox-1.20.2]$ ls ../../rootfs/rootfs/

apps  bin  data  dev  etc  info  lib  mnt  proc  root  sbin  sys  tmp  usr  var

没有init和linuxrc 文件

解决:3.1   [luxibao@centos ~]$  ln -s bin/busybox init

3.2

#选择:

  Busybox Settings  --->

       General Configuration  --->

             [*] Don't use /usr

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

             What kind of applet links to install (as soft-links)  --->

(home/luxibao/fl2440/rootfs/rootfs/) BusyBox installation prefix(改对路径)


4.[luxibao@centos busybox-1.20.2]$ ln -s bin/busybox init   路径弄错。

 

解决:用sudo权限删除掉busybox-1.20.2文件夹 重新做busybox-1.20.2.tar.bz2解压和安装busybox

5.[luxibao@centos dropbear-0.53.1]$ /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip ssh

/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip: 'ssh': No such file

 

解决:[luxibao@centos dropbear-0.53.1]$ mv dbclient ssh

[luxibao@centos dropbear-0.53.1]$ /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip ssh

你可能感兴趣的:(根文件制作)