編譯 Ubuntu 根文件系統
環境:
Ubuntu 16.04 amd64
安裝依賴包:
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
下載 Ubuntu core:
wget -c http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.1/release/ubuntu-base-16.04.1-base-arm64.tar.gz
創建一個大小為 1000M 的根文件系統映像文件,并使用 Ubuntu 的基礎包去初始化:
fallocate -l 1000M rootfs.img sudo mkfs.ext4 -F -L ROOTFS rootfs.img mkdir mnt sudo mount rootfs.img mnt sudo tar -xzvf ubuntu-base-16.04.1-base-arm64.tar.gz -C mnt/ sudo cp -a /usr/bin/qemu-aarch64-static mnt/usr/bin/
qemu-aarch64-static是其中的關鍵,能在 x86_64 主機系統下 chroot 到 arm64 文件系統:
Chroot 到新的文件系統中去并初始化:
sudo chroot mnt/ # 這里可以修改設置 USER=firefly HOST=firefly # 創建用戶 useradd -G sudo -m -s /bin/bash $USER passwd $USER # 輸入密碼 # 設置主機名和以太網 echo $HOST > /etc/hostname echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts echo "127.0.0.1 $HOST" >> /etc/hosts echo "auto eth0" > /etc/network/interfaces.d/eth0 echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0 echo "nameserver 127.0.1.1" > /etc/resolv.conf # 使能串口 ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service # 安裝包 apt-get update apt-get upgrade apt-get install ifupdown net-tools network-manager apt-get install udev sudo ssh apt-get install vim-tiny
卸載文件系統:
sudo umount rootfs/
Credit: bholland
-
嵌入式主板
+關注
關注
7文章
6086瀏覽量
35609 -
Firefly
+關注
關注
2文章
538瀏覽量
7129 -
RK3328
+關注
關注
1文章
55瀏覽量
3041
發布評論請先 登錄
相關推薦
評論