轉自: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 命令安裝各類軟件包,不再用繁瑣的交叉編譯工做了。