§2023-10-07
- Gentoo on ODROID C2 Published on December 20, 2020 Author Artem Butusov
- BredOS aarch64 Download
- Compile orangepi5 +, u-boot
This is a pseudo method to replace exisitng running Debian, ubuntu, archlinux... systems to run Gentoo style OS. The kernel is the old distribution, and can not be updated latter.
Here we will fill the gap and install Gentoo Linux on ODROID C2. The instruction should be relatively easy to update for other ODROID boxes,like, ODROID C4 etc.
Inspired by a short but a bit outdated instruction located here: https://forum.odroid.com/viewtopic.php?t=21675
Orangepi5plus_1.0.6_ubuntu_jammy_desktop_gnome_linux5.10.110.img
and balena-etcher to etche it
alexlai@MacMini OrangePi % scp Orangepi5plus_1.0.6_ubuntu_jammy_desktop_gnome_linux5.10.110.img 192.168.48.247:/home/alexlai
§2023-09-28
I sucessfuly booted up a odroid-hc4 following this arcticle.
1). Start with BreadOS
- boot it up and prepare /dev/nvmnp as
root@orgpi516G /h/alexlai# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
mtdblock0 31:0 0 16M 0 disk <-- BredOS
mmcblk0 179:0 0 15G 0 disk
├─mmcblk0p1 179:1 0 128M 0 part /boot
└─mmcblk0p2 179:2 0 14.8G 0 part /
zram0 254:0 0 15.4G 0 disk [SWAP]
nvme0n1 259:0 0 238.5G 0 disk <-- to be Gentoo
├─nvme0n1p1 259:1 0 1G 0 part
├─nvme0n1p2 259:2 0 16G 0 part
└─nvme0n1p3 259:3 0 64G 0 part
- Download Gentoo stage3
$ curl https://distfiles.gentoo.org/releases/arm64/autobuilds/20231022T231657Z/stage3-arm64-desktop-systemd-20231022T231657Z.tar.xz --output stage3-arm64-desktop-systemd-20231022T231657Z.tar.xz
$ mkdir -p /mnt/gentoo
$ sudo moount /dev/nvme0n1p3 /mnt/gentoo/
$ sudo tar xvf stage3-arm64-desktop-systemd-20231022T231657Z.tar.xz -C /mnt/gentoo/
- Backup vanilla orabgepi5 kernel and configuration
In Linux, the /opt directory is typically used for the installation of additional software packages or add-on packages that are not part of the default operating system distribution. It's a directory where software vendors can place their applications and associated files without interfering with the system's package manager or system files.
$ sudo mkdir /mnt/gentoo/opt/BredOS
$ sudo cp -rfav /lib/modules /mnt/gentoo/opt/BredOS/
$ sudo cp -rfav /lib/firmware /mnt/gentoo/opt/BredOS/
$ sudo cp -rfav /boot /mnt/gentoo/opt/BredOS/
$ sudo cp -rfav /etc/fstab /mnt/gentoo/opt/BredOS/
ls /mnt/gentoo/opt/BredOS/
boot firmware fstab modules
)
5) arch-chroot
$ sudo pacman -S arch-install-scripts $ sudo arch-chroot /mnt/gentoo/ /bin/bash orgpi516G / # source /etc/profile orgpi516G / # export PS1="(chroot) $PS1"
6) arch-chroot
root@orangepi5plus:~# arch-chroot /mnt/gentoo/ /bin/bash orangepi5plus / # source /etc/profile orangepi5plus / # export PS1="(chroot) $PS1"
7) Skip this --> edit /etc/resolv.conf as
nameserver 8.8.8.8 nameserver 8.8.4.4
- ` ping -c 3 google.com `
8) copy the saved
(chroot) orgpi516G / # mount /dev/nvme0n1p1 /boot (chroot) orgpi516G / # ls /opt/BredOS/ boot firmware fstab modules (chroot) orgpi516G / # cp -rfav /opt/BredOS/boot/* /boot (chroot) orgpi516G / # cp -rfav /opt/BredOS/firmware /lib (chroot) orgpi516G / # cp -rfav /opt/BredOS/modules /lib
9) /etc/fstab
#LABEL=boot /boot ext4 defaults 1 2 UUID=5fd3fa9c-718b-4201-8c9f-f2a111a1040c /boot ext4 defaults 1 2 #LABEL=swap UUID=6fa3809e-2a9b-4f6d-a075-9a32ac7f5469 none swap sw 0 0 #LABEL=root UUID=f3363c71-285c-4388-ba15-3a50c36bbcdc / ext4 defaults 0 1
/dev/nvme0n1p1: UUID="5fd3fa9c-718b-4201-8c9f-f2a111a1040c" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="38959b19-01ed-472a-9bb3-958e29f6b9a5"
/dev/nvme0n1p2: UUID="6fa3809e-2a9b-4f6d-a075-9a32ac7f5469" TYPE="swap" PARTLABEL="Linux swap" PARTUUID="ec78a151-e3fc-4ffd-90b0-bde2061ee86d"
/dev/nvme0n1p3: UUID="f3363c71-285c-4388-ba15-3a50c36bbcdc" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="c5e404be-2fe5-4f5c-bc7c-633de3b17c22"
10) /boot
- from
(chroot) orgpi516G / # cat /boot/extlinux/extlinux.conf
label BredOS ARM kernel /vmlinuz-linux-orangepi5 initrd /initramfs-linux-orangepi5.img fdt /dtbs/rockchip/rk3588-orangepi-5-plus.dtb append root=PARTUUID=a7f279d3-752a-4a4a-ad69-8de9f633ae0e earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=0 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M
- to
label BredOS ARM kernel /vmlinuz-linux-orangepi5 initrd /initramfs-linux-orangepi5.img fdt /dtbs/rockchip/rk3588-orangepi-5-plus.dtb append root=PARTUUID=c5e404be-2fe5-4f5c-bc7c-633de3b17c22 earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=0 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.>
11) ` nano nano /etc/systemd/network/50-wired.network` <-- each interface hs its own rule
[Match] Name=enP3p49s0
[Network] DHCP=yes
12) useradd alexlai
(chroot) orgpi516G / # useradd -u 1026 -m -G wheel,video alexlai (chroot) orgpi516G / # passwd alexlai
- reset root password, no passwd
# sed -i 's/^root:.*/root::::::::/' /etc/shadow
-
exit and boot
-
If booted up uding
dhcpcd end0
to get ip
Post-reboot Installation
Disconnect eMMC/SD card and attach to ODROID C2, connect power and ethernet cord.
After boot:
- SSH into ODROID C2
Wait for some time and find new IP in the router settings and try to ssh using username “root” and password “gentoo”.
You can also find an IP using network scanner nmap:
nmap -p 22 192.168.50.1/24 | grep open -B 4
SSH using know IP address:
ssh root@A.B.C.D
If you have serial console cable, you can connect using it and track the boot process from macOS:
screen /dev/tty.SLAB_USBtoUART 115200
- Set time
ODROID C2 doesn’t have RTC so every time it reboots it will forget current time.
We will install later ntp to address this issue but for now we need to manually set the clock, otherwise, nothing will work well.
You can run date on macOS and copy paste into terminal like below:
date -s "Sat Dec 19 21:04:49 EST 2020"
- Install portage
mkdir -p /etc/portage/repos.conf cp -f /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf emerge-webrsync
- Install ntp server
ODROID-C2 doesn’t have RTC so every time it reboots it will forget current time.
Classical ntp doesn’t play well for systems without RTC (like ODROID C2), so lets install chrony instead that has support for systems without RTC.
emerge chrony
nano /etc/conf.d/chronyd ARGS="... -s -r"
rc-update add chronyd default
/etc/init.d/chronyd start
Default hwclock init script is useless without RTC:
rc-update delete hwclock boot
Reboot and confirm that clock is properly set.
- Done
Okay, the minimal Gentoo installation is completed. It boots and new packages can be installed.
Please follow official Gentoo instruction to change defaults like locale, timezone, make.conf etc: https://wiki.gentoo.org/wiki/Handbook:AMD64/Full/Installation References
https://wiki.gentoo.org/wiki/Handbook:AMD64/Full/Installation
https://forum.odroid.com/viewtopic.php?t=21675
https://archlinuxarm.org/platforms/armv8/amlogic/odroid-c2
One Response to Gentoo on ODROID C2
David says:
April 22, 2021 at 8:42 am
Interesting take on the install. I also use gentoo on the C2, and it works really great.
Did you know about this overlay?
https://github.com/nxmyoz/c2-overlay
The instructions on how to use the official sys-kernel/gentoo-sources kernel are there, in case you want the ability to easily upgrade and customize it.
It’s also possible to install without a virtual machine, or even a second computer. I used arch linux on the c2 running on an sd card to create a gentoo install from scratch on a second sd card via a usb sd adapter. It took a day to compile gcc, and an another day to (re)compile everything else. Having swap space isn’t strictly necessary, although gcc can only compile this way using 1 thread and no “-pipe” CFLAG.