Chinaunix首页 | 论坛 | 博客
  • 博客访问: 962136
  • 博文数量: 109
  • 博客积分: 554
  • 博客等级: 中士
  • 技术积分: 2577
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-04 12:49
文章分类

全部博文(109)

文章存档

2019年(5)

2016年(7)

2015年(9)

2014年(1)

2013年(71)

2012年(16)

分类: LINUX

2015-05-22 16:14:56

下载解压busybox

tar xf busybox-1.20.2.tar.bz2

 

设置交叉编译器

enzo@debian:~/work/tq2416/tmp_rootfs/busybox-1.20.2$ arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/maxim/arm-lite/src-4.3-arm-none-linux-gnueabi-lite/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q1-176' --with-bugurl= --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/maxim/arm-lite/install-4.3-arm-none-linux-gnueabi-lite/arm-none-linux-gnueabi/libc --with-gmp=/scratch/maxim/arm-lite/obj-4.3-arm-none-linux-gnueabi-lite/host-libs-2009q1-176-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/maxim/arm-lite/obj-4.3-arm-none-linux-gnueabi-lite/host-libs-2009q1-176-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/maxim/arm-lite/install-4.3-arm-none-linux-gnueabi-lite/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/maxim/arm-lite/install-4.3-arm-none-linux-gnueabi-lite/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176)

 

修改Makefile 交叉编译器

164行  CROSS_COMPILE ?= arm-linux-

 

配置busybox

选上以下几项:
Busybox Settings --->
         Build Options --->
               [*] Build BusyBox as a static binary (no shared libs)
               [*] Build with Large File Support (for accessing files > 2 GB)
         Busybox Library Tuning --->
               [*] vi-style line editing commands
               [*] Fancy shell prompts
Linux Module Utilities --->
        [ ] Simplified modutils
        [*] insmod
        [*] rmmod
        [*] lsmod
        [*] modprobe
        [*] depmod


编译

make

make install

在busybox目录下产生_install子目录,这就是刚编译好busybox生成文件目录

改名

mv _install rootfs_2416

 

创建脚本自动生成一些默认目录和文件

#!/bin/sh
#root dir
mkdir bin sbin lib etc dev sys proc tmp var opt mnt usr home root media
#usr sub dir
cd usr
mkdir bin sbin lib local
#usr/local sub dir
cd local
mkdir bin sbin lib
cd ../..
#etc sub dir
cd etc
touch inittab
touch fstab
touch profile
touch passwd
touch group
touch shadow
touch resolv.conf
touch mdev.conf
touch inetd.conf
mkdir rc.d
mkdir init.d
mkdir udev
touch init.d/rcS
chmod +x init.d/rcS
mkdir sysconfig

touch sysconfig/HOSTNAME
cd ..
#dev sub dir
cd dev
sudo mknod console c 5 1
sudo chmod 777 console
sudo mknod null c 1 3
sudo chmod 777 null
cd ..
#var sub dir
cd var
mkdir log
cd ..

 

将交叉编译器动态库拷贝到文件系统

cp /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/libc/armv4t/lib/*so* ./lib -a

cp /opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*so* usr/lib –a

 

/etc/fstab 内容:

#device        mount-point    type    options        dump    fsck order
proc        /proc        proc    defaults        0    0
tmpfs        /tmp        tmpfs    defaults        0    0
sysfs        /sys        sysfs    defaults        0    0
tmpfs        /dev        tmpfs    defaults        0    0
var        /dev        tmpfs    defaults        0    0
ramfs        /dev        ramfs    defaults        0    0

/etc/inittab内容:

::sysinit:/etc/init.d/rcS
console::askfirst:-bin/sh
::ctrlaltdel:-/sbin/reboot
::restart:/sbin/init

 

/etc/init.d/rcS内容:

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel

mount -a
echo "
            _ _ _ _ _ _ _ _ _ _ _ _
            \  _  _   _  _ _ ___
            / /__/ \ |_/
           / __   /  -  _ ___
          / /  / /  / /
  _ _ _ _/ /  /  \_/  \_ ______
___________\___\__________________
"

#当使用udev时不能制作文件系统时静态创建
mknod -m 666 /dev/console c 5 1
mknod -m 666 /dev/null c 1 1
mkdir /dev/pts
mount -t devpts devpts /dev/pts
##############################mdev start##############################
#echo /sbin/mdev > /proc/sys/kernel/hotplug
#mdev -s

##############################udev start##############################

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

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

ifconfig eth0 192.168.101.101 netmask 255.255.255.0 up
ifconfig lo 127.0.0.1

 

/etc/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

export LD_LIBRARY_PATH=lib:/usr/lib:$LD_LIBRARY_PATH


/etc/passwd内容:

root::0:0:root:/:/bin/sh
ftp::0:0:FTP User:/:

nobody:*:99:99:Nobody:/:

/etc/group内容

root:*:0:
daemon:*:1:
bin:*:2:
sys:*:3:
adm:*:4:
tty:*:5:
disk:*:6:
lp:*:7:lp
mail:*:8:
news:*:9:
uucp:*:10:
proxy:*:13:
kmem:*:15:
dialout:*:20:
fax:*:21:
voice:*:22:
cdrom:*:24:
floppy:*:25:
tape:*:26:
sudo:*:27:
audio:*:29:
ppp:x:99:
sky:x:1000:
TQ2416:x:1002:

 

/etc/inetd.conf:

 

# /etc/inetd.conf:  see inetd(8) for further informations.
#
# Internet server configuration database
#
#
# If you want to disable an entry so it isn't touched during
# package updates just comment it out with a single '#' character.
#
# If you make changes to this file, either reboot your machine or
# send the inetd process a HUP signal:
# Do a "ps x" as root and look up the pid of inetd. Then do a
#     kill -HUP
# inetd will re-read this file whenever it gets that signal.
#
#
#:INTERNAL: Internal services
# It is generally considered safer to keep these off.
echo     stream  tcp    nowait    root    internal
echo     dgram   udp    wait    root    internal
#discard  stream  tcp    nowait    root    internal
#discard  dgram   udp    wait    root    internal
daytime  stream  tcp    nowait    root    internal
daytime  dgram   udp    wait    root    internal
#chargen  stream  tcp    nowait    root    internal
#chargen  dgram   udp    wait    root    internal
time     stream  tcp    nowait    root    internal
time     dgram   udp    wait    root    internal

# These are standard services.
#
ftp    stream    tcp    nowait    root    /usr/sbin/ftpd    /usr/sbin/ftpd
telnet    stream    tcp    nowait    root    /usr/sbin/telnetd    /usr/sbin/telnetd -i
#nntp    stream    tcp    nowait    root    tcpd    in.nntpd
#smtp  stream  tcp     nowait  root    tcpd    sendmail -v
#
# Shell, login, exec and talk are BSD protocols.
#
# If you run an ntalk daemon (such as netkit-ntalk) on the old talk
# port, that is, "talk" as opposed to "ntalk", it won't work and may
# cause certain broken talk clients to malfunction.
#
# The talkd from netkit-ntalk 0.12 and higher, however, can speak the
# old talk protocol and can be used safely.
#
#shell    stream    tcp    nowait    root    /usr/sbin/tcpd    in.rshd -L
#login    stream    tcp    nowait    root    /usr/sbin/tcpd    in.rlogind -L
#exec    stream    tcp    nowait    root    /usr/sbin/tcpd    in.rexecd
#talk    dgram    udp    wait    root    /usr/sbin/tcpd    in.talkd
#ntalk    dgram    udp    wait    root    /usr/sbin/tcpd    in.talkd
#
# Pop et al
# Leave these off unless you're using them.
#pop2    stream    tcp    nowait    root    /usr/sbin/tcpd    in.pop2d
#pop3    stream    tcp    nowait    root    /usr/sbin/tcpd    in.pop3d
#
# The Internet UUCP service.
# uucp    stream    tcp    nowait    uucp    /usr/sbin/tcpd    /usr/lib/uucp/uucico    -l
#
# Tftp service is provided primarily for booting.  Most sites
# run this only on machines acting as "boot servers." If you don't
# need it, don't use it.
#
#tftp    dgram    udp    wait    nobody    /usr/sbin/tcpd    in.tftpd
#bootps    dgram    udp    wait    root    /usr/sbin/in.bootpd    in.bootpd
#
# Finger, systat and netstat give out user information which may be
# valuable to potential "system crackers."  Many sites choose to disable
# some or all of these services to improve security.
#
#finger    stream    tcp    nowait    nobody    /usr/sbin/tcpd    in.fingerd -w
#systat    stream    tcp    nowait    nobody    /usr/sbin/tcpd    /bin/ps    -auwwx
#netstat    stream    tcp    nowait    root    /bin/netstat    /bin/netstat    -a
#ident    stream    tcp    nowait    root    /usr/sbin/in.identd    in.identd

 

 

/etc/services

tcpmux        1/tcp
echo        7/tcp
echo        7/udp
systat        11/tcp        users
daytime        13/tcp
daytime        13/udp
netstat        15/tcp
ftp-data    20/tcp
ftp        21/tcp
ssh        22/tcp
ssh        22/udp
telnet        23/tcp
smtp        25/tcp        mail
time        37/tcp        timserver
time        37/udp        timserver
nameserver    42/tcp        name
whois        43/tcp        nicname
bootps        67/tcp                # BOOTP server
bootps        67/udp
bootpc        68/tcp                # BOOTP client
bootpc        68/udp
tftp        69/udp
finger        79/tcp
www        80/tcp        http
www        80/udp
pop3        110/tcp        pop-3
pop3        110/udp        pop-3
sunrpc        111/tcp        portmapper
sunrpc        111/udp        portmapper
auth        113/tcp        authentication tap ident
nntp        119/tcp        readnews untp
ntp        123/tcp
ntp        123/udp
snmp        161/udp
snmp-trap    162/udp        snmptrap


使用udev自动挂载u盘,sd卡等设备

编译udev

tar xzf udev-100.tgz
make -C udev-100 CROSS_COMPILE=arm-linux- 
   将生成的下列文件 udevd,     udevstart,  udevinfo   拷贝到根文件系统/bin目录下

udev配置文件

etc/udev/
├── rules.d
│   ├── 11-addusb.rules
│   ├── 12-removeusb.rules
│   ├── 54-gphoto.rules
│   ├── 60-pcmcia.rules
│   ├── 75-cd-aliases-generator.rules.optional
│   ├── 75-persistent-net-generator.rules.optional
│   ├── 90-hal.rules
│   ├── 97-bluetooth-serial.rules
│   ├── 99-fuse.rules
│   ├── device-mapper.rules
│   ├── mount-usb.sh
│   └── umount-usb.sh
└── udev.conf

 

udev.conf:

cat udev.conf
# udev.conf
# The initial syslog(3) priority: "err", "info", "debug" or its
# state can be changed with: "udevcontrol log_priority=".
udev_root="/dev/"
udev_rules="/etc/udev/rules.d"
udev_log="err"

 

cat 11-addusb.rules
ACTION=="add", KERNEL=="sd[a-z]*", RUN+="/etc/udev/rules.d/mount-usb.sh %k"

 

cat 12-removeusb.rules
ACTION=="remove", KERNEL=="sd[a-z]*", RUN+="/etc/udev/rules.d/umount-usb.sh"

 

cat mount-usb.sh
#!/bin/sh
/bin/mount -t vfat /dev/$1 /udisk

 

cat umount-usb.sh
#!/bin/sh
sync
#umount /dev/$1
umount /udisk

 

制作文件系统镜像

阅读(2601) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~