OS: ubuntu 18.04
使用debootstrap製作根文件系統會分成兩個階段。第一階段是,使用debootstrap命令來下載軟件包。 第二階段是安裝軟件包。
安裝debootstap 等相關工具
$ sudo apt install binfmt-support qemu qemu-user-static debootstrap
使用debootstrap 下載軟件包
$ mkdir debian10_mips64el
$ sudo debootstrap --arch mips64el --foreign buster debian10_mips64el http://mirrors.ustc.edu.cn/debian/
--arch:指定要製作文件系統的處理器體系結構,比如mipsel或者mips64el
buster:指定Debian的版本。buster是Debian10系統的代號。
debian10_mips64el:本地目錄,最後製作好的文件系統會在此目錄。
--foreign:只執行引導的初始解包階段,僅僅下載和解壓。
http:/mirrors.ustc.edu.cn/debian/:國內中科大鏡像源地址
因爲主機跑在x86架構上,而我們要製作的文件系統是跑在龍芯上,因此可以使用qemu-mips64el-static來模擬成mips64el的執行環境。
$ cp /usr/bin/qemu-mips64el-static debian10_mips64el/usr/bin/
通過chroot 使用debootstrap命令進行軟件包的安裝和配置。其中命令參數--second-stage表示執行第二階段的安裝
$ sudo chroot debian10_mips64el/ debootstrap/debootstrap --second-stage
顯示"I:Base system installed successfully."這句話,說明第二階段已經完成。
通過chroot 進入剛製作的根文件系統
$ sudo chroot debian10_mips64el/
設置密碼
# passwd root
配置網卡支持DHCP協議。修改/etc/network/interfaces文件,增加如下內容。
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp