转自:http://www.cnblogs.com/qiaoqiao2003/p/3738552.htmlhtml
转自:http://blog.csdn.net/luoqindong/article/details/42737879linux
debootstrap: https://wiki.debian.org/Debootstrapbootstrap
multistrap: https://wiki.debian.org/Multistrapapi
cross-debootstrapping: https://wiki.debian.org/EmDebian/CrossDebootstrap架构
cdebootstrap: https://wiki.debian.org/cdebootstrapapp
debian系统有针对arm分支的,在arm上跑debian系统能够用apt-get安装软件,避免繁琐的编译和重复建立文件系统的工做.
本例子使用z-turn的开发板为例.
linux主机版本:工具
root@v:i# lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.7 (wheezy) Release: 7.7 Codename: wheezy
$ sudo apt-get install binfmt-support qemu qemu-user-static debootstrap multibootstrap
debootstrap ---- 一个 Debian 提供的工具,能够用来生成指定构架的文件系统
qemu ---- 用于模拟 arm 环境ui
在opt下建立文件系统目录fs_debian_wheezy
$sudo debootstrap --arch=armel --foreign wheezy fs_debian_wheezy http://cdn.debian.net/debian(http://ftp.debian.org/debian/)
arch指定了cpu架构, wheezy指定Debian系统代号,可在网上找不一样的debian版本对应的代号.
上面的命令我这边要运行2次,spa
第一次出现这样的信息:.net
I: Retrieving libxapian22 I: Validating libxapian22 I: Retrieving liblzma5 I: Validating liblzma5 I: Retrieving xz-utils I: Validating xz-utils I: Retrieving zlib1g I: Validating zlib1g
下载的时候有些warning, 提示有些库下载不了,这个不影响.
第2次是这样的信息:
I: Extracting bsdutils... I: Extracting libblkid1... I: Extracting libmount1... I: Extracting libuuid1... I: Extracting mount... I: Extracting util-linux... I: Extracting liblzma5... I: Extracting xz-utils... I: Extracting zlib1g...
从信息上看,第一次是从网上下载,第二次是将文件抽取出来,第2次以后,在fs_debian_wheezy目录下才有bin,sbin等linux文件系统目录.
由于在宿主是 x86 架构,不能安装 arm 架构的软件。须要依靠 qemu-arm-static 来
模拟成 arm 环境进行安装。
$ sudo cp /usr/bin/qemu-arm-static fs_debian_wheezy/usr/bin
$ sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot fs_debian_wheezy debootstrap/debootstrap --second-stage
该命令意思是设置一些环境变量,而后切换根目录到fs_debian_wheezy,执行目录fs_debian_wheezy/debootstrap下的命令: debootstrap --second-stage.
终端上会最后打印 I: Base system installed successfully.,说明根文件系统就定制成功了。
$sudo cd fs_debian_wheezy $sudo echo "proc /proc proc defaults 0 0" >> etc/fstab $sudo mkdir -p usr/share/man/man1/ 若是dev/console设备节点不存在,也须要建立 $sudo mknod dev/console c 5 1
$sudo chroot fs_debian_wheezy
# vi /etc/apt/source.list deb http://cdn.debian.net/debian wheezy main contrib non-free deb-src http://cdn.debian.net/debian wheezy main contrib non-free # apt-get update 更新软件
# passwd root
debian不能以root用户登录,因此建立一个普通用户,登录系统后再切换到root用户
# adduser qq
# passwd qq 设置用户i的密码
# cp /usr/share/usr/share/sysvinit/inittab /etc/
# vi /etc/inittab
找到 #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100,大约在 63 行左右
修改成 T0:23:respawn:/sbin/getty -L ttyPS0 115200 vt100,此处依据本身的实际状况修改
# exit
至此,一个基本的根文件系统就订制完了。把根文件系统拷贝到SD卡上,插到ARM板上,设置z-turn从SD卡加载根文件系统,若是一切顺利一个debian 系统就运行起来了。能够用apt-get 命令安装各类软件包,不再用繁琐的交叉编译工做了。