OrangePi PC 替代法完成Gentoo鏡像制作

  • Gentoo 是屬于’極為簡(jiǎn)潔優(yōu)秀超可定制性的類(lèi)Unix’的Linux..
    Gentoo包管理系統(tǒng)的設(shè)計(jì)是模塊化、可移植、易維護(hù)、靈活以及針對(duì)用戶(hù)機(jī)器優(yōu)化的。Gentoo維基百科

  • 很多人遇到Gentoo,都會(huì)選擇放棄,折騰的話(huà),很費(fèi)力氣的,從頭到尾都是去編譯。但是用Gentoo的玩家,都會(huì)蔑視用 Ubuntu的用戶(hù),覺(jué)得他們太低端了。

  • 今天我們不從編譯的角度去構(gòu)建 Gentoo For OrangePi PC,如果你想在你的樹(shù)莓派上跑Gentoo,Gentoo官方還是提供了供樹(shù)莓派使用的鏡像。

  • 先決條件:

    • 儲(chǔ)存卡(至少4G,更好8G以上)
    • OrangePi PC的Linux SD卡鏡像(官方或者Armbian的都行)
    • Gentoo armv7a_hardfp stage3鏡像 或者本地鏡像的portage樹(shù)的當(dāng)前快照
  • 準(zhǔn)備SD卡

    • 我們需要將引導(dǎo)加載程序和內(nèi)核從映像傳輸?shù)絊D卡。引導(dǎo)加載程序駐留在第一個(gè)分區(qū)之前的未分區(qū)空間中,內(nèi)核駐留在第一個(gè)分區(qū)中。
  • 復(fù)制引導(dǎo)加載程序和內(nèi)核

    • 如果壓縮圖像,請(qǐng)解壓縮。我們假設(shè)該圖像稱(chēng)為Debian_jessie_mini.img,SD卡是/ dev / sdb。根據(jù)需要調(diào)整以配合您的配置。看圖像分區(qū)結(jié)構(gòu):

root #fdisk -l Debian_jessie_mini.img
Disk Debian_jessie_mini.img: 809 MiB, 848297984 bytes, 1656832 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9c2e57c2
Device                  Boot  Start     End Sectors  Size Id Type
Debian_jessie_mini.img1       40960  172031  131072   64M  b W95 FAT32
Debian_jessie_mini.img2      172032 1656832 1484801  725M 83 Linux

在這種情況下,我們將直接復(fù)制圖像,直到引導(dǎo)分區(qū)結(jié)束到microSD卡。


root #dd if=Debian_jessie_mini.img of=/dev/sdb count=172032

接下來(lái),我們將刪除上一個(gè)根分區(qū)的分區(qū)表?xiàng)l目,然后創(chuàng)建新的根和可選的交換分區(qū)。


root #fdisk /dev/sdb
Welcome to fdisk (util-linux 2.26.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-32372735, default 2048): 172032
Last sector, +sectors or +size{K,M,G,T,P} (2048-32372735, default 32372735):
(choose here the size for your root partition, repeat with the swap partition if you want one, then set the appropriate partition types)
Command (m for help): w

  • 設(shè)置根分區(qū)
    我們假設(shè)根分區(qū)是/ dev / sdb2,交換分區(qū)是/ dev / sdb3。

使用標(biāo)簽“l(fā)inux”和交換空間創(chuàng)建根文件系統(tǒng)。


root #mkfs.ext4 -L linux /dev/sdb2
root #mkswap /dev/sdb3

  • 將Gentoo安裝到SD卡
    安裝根分區(qū)并提取stage3 tarball和portage快照。

root #mkdir /mnt/opipc
root #mount /dev/sdb2 /mnt/opipc
root #tar xfa stage3-armv7a_hardfp-????????.tar.bz2 -C /mnt/opipc
root #tar xfa portage-latest.tar.xz -C /mnt/opipc/usr

如果原始的Linux映像支持多個(gè)電路板,請(qǐng)安裝引導(dǎo)分區(qū),并為Orange Pi PC選擇正確的uImage和script.bin。


root #mount /dev/sdb1 /mnt/opipc/boot
root #cp /mnt/opipc/boot/script.bin.OPI-PC_1080p60 /mnt/opipc/boot/script.bin
root #cp /mnt/opipc/boot/uImage_OPI-2 /mnt/opipc/boot/uImage

現(xiàn)在從圖像中提取內(nèi)核模塊并將其復(fù)制到Gentoo系統(tǒng)中:


root #mkdir /mnt/opipc_image
root #mount -o loop,offset=$((172032*512)) Debian_jessie_mini.img /mnt/opipc_image
root #cp -a /mnt/opipc_image/lib/modules /mnt/opipc/lib

  • 最后完成配置
    • 編輯 fstab
/ dev / mmcblk0p1 / boot vfat umask = 033 1 2
/ dev / mmcblk0p2 / ext4 defaults 0 1
/ dev / mmcblk0p3 none swap sw 0 0

  • 設(shè)置root密碼

root #sed -i "s|root:\*|root:$(openssl passwd -1)|" /mnt/opipc/etc/shadow
Password:
Verifying - Password:

  • 在make.conf中設(shè)置編譯器并生成標(biāo)志

    CFLAGS="-O2 -pipe -march=armv7ve -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mtune=cortex-a7"
    CXXFLAGS="${CFLAGS}"
    MAKEOPTS="-j4"

  • 要通過(guò)調(diào)試ttl uart工作,請(qǐng)更改

s0:12345:respawn:/ sbin / agetty -L 9600 ttyS0 vt100


s0:12345:respawn:/ sbin / agetty -L -f /etc/issue.logo 115200 ttyS0 vt100

  • 現(xiàn)在卸載所有內(nèi)容,將SD卡插入Orange Pi PC,然后打開(kāi)電源。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Ubuntu的發(fā)音 Ubuntu,源于非洲祖魯人和科薩人的語(yǔ)言,發(fā)作 oo-boon-too 的音。了解發(fā)音是有意...
    螢火蟲(chóng)de夢(mèng)閱讀 100,830評(píng)論 9 468
  • 學(xué)習(xí)stm32gpio 學(xué)習(xí)linux 程序員的三大方向 程序員的方向,一般可以分為3類(lèi):專(zhuān)業(yè)領(lǐng)域、業(yè)務(wù)領(lǐng)域、操作...
    王公民閱讀 979評(píng)論 0 3
  • 各位linux愛(ài)好者和使用者都自己習(xí)慣使用的版本,本人之前一直使用的是centos7,但是為了裝逼(不錯(cuò)就是這個(gè)理...
    小Gentoo愛(ài)好者閱讀 11,754評(píng)論 6 26
  • tags: Linux OS GRUB 硬盤(pán)分區(qū) 背景 2016年雙十一入手了一塊500G的 SSD(Solid ...
    CntChen閱讀 11,391評(píng)論 2 20
  • 雖然己經(jīng)過(guò)去了三年了,但是那段驚心動(dòng)魄的日子,仿佛在昨日。 因?yàn)楹颓澳杏褎偡质?,心情很傷心很郁悶,久久不能釋?xiě)?,?..
    Angel李子汐閱讀 596評(píng)論 38 25

友情鏈接更多精彩內(nèi)容