象棋小子 1048272975 Ubuntu是一個(gè)廣泛應(yīng)用于個(gè)人電腦,云計(jì)算,以及智能物聯(lián)網(wǎng)設(shè)備的開源操作系統(tǒng)。針對(duì)智能物聯(lián)網(wǎng),Ubuntu提供了一套更加安全,輕量級(jí),專為智能物聯(lián)網(wǎng)訂制的開源操作系統(tǒng)Ubuntu Core。它已被廣泛應(yīng)用于物聯(lián)網(wǎng),智能設(shè)備和自主設(shè)備等嵌入式產(chǎn)品中。 1. 下載Ubuntu CoreUbuntu Core是Ubuntu的一個(gè)精簡(jiǎn)版本,只包含Ubuntu根文件系統(tǒng)的核心部分,默認(rèn)沒有圖形界面等等。在Ubuntu主機(jī)中創(chuàng)建目錄并下載Ubuntu 16.04.02的Core根文件系統(tǒng)。 mkdir ~/rootfs && cd ~/rootfs wget http://cdimage./ubuntu-base/releases/16.04/release/ubuntu-base-16.04.2-base-arm64.tar.gz 2. 解壓Ubuntu Coresudo tar –xpf ubuntu-base-16.04.2-base-arm64.tar.gz 3. 安裝qemu安裝qemu用于在主機(jī)端模擬執(zhí)行基于arm架構(gòu)的代碼,把模擬器拷貝到Core根文件系統(tǒng)目錄中。如果是32位armhf根文件系統(tǒng)版本,拷貝qemu-arm-static,此處是64位arm64版本,拷貝qemu-aarch64-static。 sudo apt-get install qemu-user-static sudo cp -a /usr/bin/qemu-aarch64-static usr/bin/ 4. 安裝linux內(nèi)核模塊編譯linux內(nèi)核,在內(nèi)核源碼目錄output/lib/中拷貝modules目錄中的所有內(nèi)容到Core根文件系統(tǒng)/lib目錄。 5. 切換根文件系統(tǒng)切換到Core根文件系統(tǒng),進(jìn)行更新設(shè)置。 sudo chroot ../rootfs 此時(shí)處于arm模擬器Core根文件系統(tǒng)中。 6. 設(shè)置root密碼passwd root 7. 添加ubuntu管理員賬號(hào)可以添加一個(gè)ubuntu的管理員賬號(hào)并修改密碼。 useradd –G sudo –m –s /bin/bash ubuntu passwd ubuntu 8. 設(shè)置主機(jī)名可以為目標(biāo)板設(shè)置一個(gè)主機(jī)名。 echo Ubuntu > /etc/hostname echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts echo "127.0.0.1 Ubuntu" >> /etc/hosts 9. 設(shè)置DNS解析器配置文件echo "nameserver 127.0.1.1" > /etc/resolv.conf 10. 設(shè)置串口登錄ln –s /lib/systemd/system/serial-getty/@.service/etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service Ubuntu 16.04.02采用了systemd的init初始化系統(tǒng),用于提高系統(tǒng)的啟動(dòng)速度。在執(zhí)行g(shù)etty.targe時(shí),systemd會(huì)自動(dòng)在/etc/systemd/system/getty.target.wants查找相關(guān)的targe執(zhí)行,即實(shí)際執(zhí)行/lib/systemd/system/serial-getty@.service這個(gè)串口終端服務(wù)。 11. 從服務(wù)器獲取最新的包列表apt-get update 12. 安裝網(wǎng)絡(luò)工具包apt-get install ifupdown net-tools 13. 安裝udev設(shè)備管理器apt-get install udev udev用于動(dòng)態(tài)管理/dev目錄下的設(shè)備節(jié)點(diǎn)。 14. 安裝fbset工具包apt-get installfbset 15. 安裝其他的軟件包可以用apt-get安裝其他適用于目標(biāo)板的軟件包,如vim,ssh等等。 16. 安裝initramfs-tools工具apt-get install initramfs-tools 17. 生成ramdisk歸檔文件mkinitramfs -o /boot/initrd.img 3.10.65 其中3.10.65為內(nèi)核版本,可以把生成的initrd.img拷貝到linux源碼目錄,重命名并替換掉rootfs.cpio.gz,重新編譯linux內(nèi)核,并生成新boot.img。 可以通過以下命令解壓img文檔,從而實(shí)現(xiàn)修改。 mv initrd.img initrd.img.gz gunzip initrd.img.gz cpio -idmv < initrd.img 18. 退出構(gòu)建Core根文件系統(tǒng)設(shè)置好Core根文件系統(tǒng)后,用exit命令退出chroot。 19. 打包做好的Core根文件系統(tǒng)sudo tar –czvf ../ubuntu.tar.gz . 在根文件系統(tǒng)上一目錄生成ubuntu.tar.gz的文檔。 20. Core根文件系統(tǒng)更新到sd卡插入sd卡,清空rootfs目錄,把ubuntu.tar.gz拷貝到sd卡rootfs目錄,并解壓。 tar –xzvf ubuntu.tar.gz 21. ubutun啟動(dòng)22. 附錄本章所述構(gòu)建好的Ubuntu Core根文件系統(tǒng)。 http://pan.baidu.com/s/1i4Hfrvv
|
|