§2023-10-01
Gentoo on ODROID C2 Published on December 20, 2020 Author Artem Butusov
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
- Get ubuntu 20.04 image and balena-etcher to etche it
$ wget https://odroid.in/ubuntu_20.04lts/c2/ubuntu-20.04-3.16-minimal-odroid-c2-20210201.img.xz
§2023-09-28
I sucessfuly booted up a odroid-hc4 following this arcticle.
1). I use netboot_default
to install Debian 11, Bullseye on a 246G MicroSD. and make sure it could be booted up.
- Mount eMMC/SD card
mkdir -p /mnt/gentoo
mount /dev/nvme0n1p2 /mnt/gentoo/
mount /dev/nvme0n1p1 /mnt/gentoo/boot
cd /mnt/gentoo
- Backup vanilla orabgepi5 kernel and configuration
mkdir -p opt/orangepi5+-backup
# pwd
/mnt/gentoo
cp -rfav lib/modules opt/orangepi5+-backup
cp -rfav lib/firmware opt/orangepi5+-backup
cp -rfav boot opt/orangepi5+-backup
cp -av etc/fstab opt/orangepi5+-backup
# ls opt/orangepi5+-backup/ <---- make sure
5.10.110-rockchip-rk3588 boot firmware fstab modules
4) Remove not needed stuff
pwd
/mnt/gentoo
find . -maxdepth 1
| while read file; do
[ "$file" != "./boot" ]
&& [ "$file" != "./opt" ]
&& [ "$file" != "./lost+found" ]
&& [ "$file" != "." ]
&& rm -rf "$file";
done
pwd
/mnt/gentoo orgpi5Gentoo /mnt/gentoo # ls -l total 24 drwxr-xr-x 4 root root 4096 1月 1 1970 boot drwx------ 2 root root 16384 6月 1 02:16 lost+found drwxrwxr-x 5 root root 4096 10月 1 09:47 opt
5) Install aarch64 stage3
pwd
/mnt/gentoo
tar xvpf stage3-* --xattrs-include='.' --numeric-owner rm -f stage3-*
6)
apt install dhcpcd-base
copy /usr/bin/dhcpcd
and /etc/dhcpcd.conf
root@orangepi5plus:/mnt/gentoo# cp -v /etc/dhcpcd.conf etc/
'/etc/dhcpcd.conf' -> 'etc/dhcpcd.conf'
root@orangepi5plus:/mnt/gentoo# cp -v /usr/sbin/dhcpcd usr/bin
'/usr/sbin/dhcpcd' -> 'usr/bin/dhcpcd'
7) arch-chroot
- install arch-chroot
emerge --search arch-chroot
[ Results for search key : arch-chroot ] Searching...
- sys-apps/arch-chroot [ Masked ] Latest version available: 28 Latest version installed: [ Not Installed ] Size of files: 20 KiB Homepage: https://github.com/archlinux/arch-install-scripts Description: Wraps the chroot command while ensuring that important filesystems are mounted License: GPL-2
[ Applications found : 1 ]
orgpi5Gentoo / # emerge sys-apps/arch-chroot --autounmask-write --autounmask orgpi5Gentoo / # dispatch-conf orgpi5Gentoo / # cat /etc/portage/package.accept_keywords/app-i18n
package.accept_keywords# required by app-i18n/mozc (argument)
=app-i18n/mozc-2.28.5029.102-r1 ~arm64
required by app-i18n/fcitx-configtool (argument)
=app-i18n/fcitx-configtool-0.4.10 ~arm64
required by app-i18n/mozc-2.28.5029.102-r1::gentoo
required by app-i18n/mozc[fcitx4] (argument)
=dev-cpp/abseil-cpp-20230802.0 ~arm64
required by app-i18n/mozc-2.28.5029.102-r1::gentoo
required by app-i18n/mozc[fcitx4] (argument)
=dev-util/gyp-20200512145953 ~arm64
required by app-i18n/anthy (argument)
=app-i18n/anthy-9100h-r3 ~arm64
required by app-i18n/fcitx-configtool-0.4.10::gentoo
required by app-i18n/fcitx-configtool (argument)
=app-i18n/fcitx-4.2.9.8 ~arm64
required by x11-terms/terminator (argument)
=x11-terms/terminator-2.1.3 **
required by app-i18n/ibus-anthy (argument)
=app-i18n/ibus-anthy-1.5.15 **
required by gnome-base/gnome-panel (argument)
=gnome-base/gnome-panel-3.50.0 **
required by sys-block/gparted (argument)
=sys-block/gparted-1.5.0-r1 ~arm64
required by sys-apps/arch-chroot (argument)
=sys-apps/arch-chroot-28 **
- arch-chroot
root@orangepi5plus:~# arch-chroot /mnt/gentoo/ /bin/bash bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) orangepi5plus / # source /etc/profile orangepi5plus / # export PS1="(chroot) $PS1"
orgpi5Gentoo / # emerge sys-apps/arch-chroot
- edit /etc/resolv.conf as
nameserver 8.8.8.8 nameserver 8.8.4.4 ``
- make sure you can ping
ping google.com
- first sync
emerge-webrsync
- mkdir /etc/portage/repos.conf
- nano /etc/portage/repos.conf/gentoo.conf, as
[DEFAULT]
main-repo = gentoo
[gentoo]
location = /var/db/repos/gentoo
sync-type = rsync
sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4
sync-webrsync-verify-signature = yes
sync-git-verify-commit-signature = yes
emerge-webrsync
for the first time- error msgs about /var/db/repos/gentoo got the first time, it will bw created
- copy the saved
cp -rfav /opt/orangepi5+-backup/modules lib/
cp -rfav /opt/orangepi5+-backup/firmware lib/
cp -rfav /opt/orangepi5+-backup/fstab /etc
- 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.