效果图
制作根文件系统,在PC上最全面的莫过于LFS(linux form scratch),而嵌入式中 busybox 是不二之选。不过,我们这次使用debootstrap来构建文件系统。debootstrap是debian/ubuntu下的一个工具,用来构建一套基本的根文件系统,其生成的目录符合Linux文件系统标准(FHS),即包含了/boot、/etc、/bin、/usr等等目录,但它比发行版本的Linux体积小很多,当然功能也没那么强大,因此,只能说是“基本的系统”。
准备环境
安装所需依赖,使用debootstrap命令创建文件系统。
sudo apt-get install debian-archive-keyring
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
使用也十分简单,命令格式为:
sudo debootstrap --arch [平台] [发行版本代号] [构建目录] [镜像地址]
当前debootstrap支持的发行版本可以在
/usr/share/debootstrap/scripts
查看,而各发行版代号可以到http://en.wikipedia.org/wiki/List_of_Ubuntu_releases
查看。
创建版本
cd && mkdir build && cd build
这里以bionic版本为例
Armhf
sudo debootstrap --arch=armhf bionic linux-rootfs http://mirrors.ustc.edu.cn/ubuntu-ports/
sudo cp -a /usr/bin/qemu-arm-static ~/build/linux-rootfs/usr/bin/qemu-arm-static
arm64