转自:http://www.cnblogs.com/qiaoqiao2003/p/3738552.htmlhtml
Debian系统自己包含对arm的支持,其包含的软件包最多,可是最终的文件系统要大一些。linux
emdebian 是一个很是好用的嵌入式linux操做系统,其基于debian的特色对于熟悉debian系统的人来讲很容易就能驾轻就熟地进行配置。shell
emdebian有好几个版本:Grip,Crush,Baked. 关于它们的详细介绍能够查看:http://www.emdebian.org/emdebian/flavours.htmlbootstrap
一般为了便于使用,咱们选择Grip版本。bash
debian下有三个工具能够用来建立根文件系统,它们分别是Debootstrap、CDebootstrap和Multistrap,安装这几个软件:app
apt-get install debootstrap multistrap
本文中内容主要参考debian网站的CrossDebootstrap。less
debootstrap --foreign --arch armel wheezy rootfs http://ftp.debian.org/debian/
会在当前的rootfs下创建一个基本的根文件系统(名字为rootfs),而后将rootfs文件家移到nfs对应文件夹下,并重启nfs:工具
/etc/init.d/nfs-kernel-server restart
启动mini2440,按任意键进入uboot,按'q'键进入uboot命令行,将bootargs修改为如下内容:网站
noinitrd root=/dev/nfs rw nfsroot=192.168.211.2:/home/host/nfs/mini2440/rootfs ip=192.168.211.211 console=ttySAC0 init=/bin/bash
重启mini2440,可是没法进入跟文件系统,提示下面的错误:ui
Warning: unable to open an initial console.
参考http://blog.chinaunix.net/uid-10008293-id-2972298.html ,在根文件系统下建立设备文件console和null:
cd rootfs/dev mknod -m 660 console c 5 1 mknod -m 660 null c 1 3
而后重启mini2440,就能够进入根文件系统了。
而后在新的根文件系统下进行配置:
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C /debootstrap/debootstrap --second-stage
可是安装base-file是提示出错,查看/debootstrap/debootstrap.log才知道执行rmdir /var/run出错。
用ls命令能够知道该文件夹下存在一个临时文件,将该临时文件删除。而后再次执行上面的命令,可是在安装 mount时提示下面的错误:
dpkg: error processing /var/cache/apt/archives/mount_2.20.1-5.3_armel.deb (--unpack):
而后就开始尝试从新开始安装这些deb包,默认状况下会重试5次才会中止执行。尝试了半天,可是安装过程当中的错误很难追踪和修正,
我最终放弃了使用debootstrap制做基于debian的根文件系统.
步骤跟上面过程相似,先下载deb包:
debootstrap --foreign --arch armel --keyring=/usr/share/keyrings/emdebian-archive-keyring.gpg squeeze rootfs http://www.emdebian.org/grip
安装qemu-user-static包,并将qemu-arm-static拷贝到rootfs下(该工具用于避免chroot出错):
apt-get install qemu-user-static
cp /usr/bin/qemu-arm-static rootfs/usr/bin
而后安装deb包:
chroot rootfs /bin/bash /debootstrap/debootstrap --second-stage
安装过程当中提示安装dash出错,执行”dpkg -i /var/cache/apt/archives/dash_0.5.5.1-7.4em1_armel.deb”能够获得下面的输出信息:
(Reading database ... 3895 files and directories currently installed.) Unpacking dash (from .../dash_0.5.5.1-7.4em1_armel.deb) ... /bin/ln: creating symbolic link `/usr/share/man/man1/sh.1.gz.tmp': No such file or directory dpkg: error processing /var/cache/apt/archives/dash_0.5.5.1-7.4em1_armel.deb (--install): subprocess new pre-installation script returned error exit status 1 Errors were encountered while processing: /var/cache/apt/archives/dash_0.5.5.1-7.4em1_armel.deb
因为/usr/share/man文件夹不存在,因此没法建立软连接,建立文件夹:
mkdir -p /usr/share/man/man1/
而后再次执行:
/debootstrap/debootstrap --second-stage
再执行下面的命令进行配置:
echo "deb http://www.emdebian.org/grip/ squeeze main" >> rootfs/etc/apt/sources.list printf "auto eth0\niface eth0 inet dhcp\n" >> /etc/network/interfaces
而后再将该采用nfs启用根文件系统方式启动mini2440,可是进入bash前有个错误提示:
bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell
这个问题暂时做为遗留问题,有空再来研究。
该文件系统大小在七、80M左右。
cdebootstrap --foreign --arch armel wheezy rootfs http://ftp.debian.org/debian/
而后仍然用nfs启动根文件系统(选择和上面同样的bootargs),就能进入刚才制做的根文件系统。
而后用下面命令来完成deb包的解压缩和安装:
/sbin/cdebootstrap-foreign
而后执行下面的命令对全部未配置的deb包进行配置:
PATH=/usr/bin:/bin:/usr/sbin:/sbin dpkg --configure -a
如今基础的一些配置就弄好了,当前rootfs大小在200多M左右。
整个过程很是流畅,没有出现关键性错误致使安装失败的状况发生。
而后在对系统进行配置:
mount -t proc proc /proc route add default gw 192.168.211.1
而后再根据本身须要对/etc/apt/sources.list进行配置(可参考https://lug.ustc.edu.cn/repogen/)
cdebootstrap --foreign --arch armel --keyring=/usr/share/keyrings/emdebian-archive-keyring.gpg squeeze rootfs http://www.emdebian.org/grip
可是显示了下面的错误信息:
P: Retrieving InRelease P: Validating InRelease I: Good signature from "Emdebian Archive Signing Key" P: Parsing InRelease W: parser_rfc822: Iek! Don't find end of field, it seems to be after the end of the line! E: Couldn't parse InRelease!
因此后续过程也没法继续下去了。
最后使用multistrap制做根文件系统。
建立配置文件,名称为multistrap_debian.conf,内容以下:
[General] noauth=true unpack=true debootstrap=Squeeze aptsources=Squeeze arch=armel [Squeeze] packages=wpasupplicant wireless-tools firmware-ralink busybox netbase net-tools makedev source=http://ftp.au.debian.org/debian/ keyring=debian-archive-keyring components=main non-free suite=squeeze
而后执行下面的命令下载deb包并解压缩:
multistrap -a armel -d rootfs -f multistrap_debian.conf
执行完毕后将qemu-arm-static拷贝到rootfs/usr/bin下
cp /usr/bin/qemu-arm-static rootfs/usr/bin
而后chroot进入rootfs,进行配置:
chroot rootfs touch /etc/fstab mount -t proc proc /proc dpkg --configure -a
而后在mini2440下设置nfs启动根文件系统,配置与前面配置相同,但会有错误提示(不影响通常使用):
bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell
暂时做为遗留问题,留待解决。
整个文件系统大小在160M左右。
先建立配置文件,名称为multistrap_emdebian.conf,内容以下:
[General]
noauth=true
unpack=true
debootstrap=Grip
aptsources=Grip
[Grip]
# space separated package list
packages=busybox netbase net-tools ifupdown makedev
source=http://www.emdebian.org/grip
suite=squeeze
该文件中须要注意的是suite,suite类型有四种:etch,lenny,squeeze,sid分别对应oldstabe,stable,tesing,sid。
看名字基本能明白含义,只有sid不容易看明白,实际上sid表示滚动更新版本
执行下面命令制做根文件系统:
multistrap -a armel -d rootfs -f multistrap_emdebian.conf
很快就能够下载成功,并自动将deb包解压缩根文件系统下。
将/usr/bin/qemu-arm-static拷贝到rootfs/usr/bin下,而后执行以下命令进行安装后的配置:
chroot rootfs dpkg --configure -a
在配置过程当中须要选择时区,分别选择6(Asia)和65(Shanghai).
重启mini2440,采用nfs启动根文件系统(和本文前面的配置同样),但仍然会有一个错误(不影响通常使用):
bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell
这个问题仍然留待后续再解决。
生成根文件系统大小在50M左右
从前面陈述的根文件系统制做过程能够看到,mutlstrap比较利于扩展,使用也比较方便,因此我倾向于之后采用multistrap来制做根文件系统