§2023-09-27

Gentoo on ODROID C2 Published on December 20, 2020 Author Artem Butusov

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

  1. 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.

  1. Mount eMMC/SD card
mkdir -p /mnt/gentoo

mount /dev/nvme0n1p2  /mnt/gentoo/
# mkdir /mnt/gentoo/boot
mount /dev/nvme0n1p1  /mnt/gentoo/boot

cd /mnt/gentoo
  1. 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.

mkdir -p opt/orangepi5+-backup

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
> The . is used to represent the current directory, and the script is designed to exclude it from the deletion process, along with a few other specific directories (./boot, ./opt, and ./lost+found).

find . -maxdepth 1
| while read file; do
[ "$file" != "./boot" ]
&& [ "$file" != "./opt" ]
&& [ "$file" != "./lost+found" ]
&& [ "$file" != "." ]
&& rm -rf "$file";
done


5) Install aarch64 stage3

wget https://distfiles.gentoo.org/releases/arm64/autobuilds/20230924T230144Z/stage3-arm64-desktop-systemd-20230924T230144Z.tar.xz

tar xvpf stage3-* --xattrs-include='*.*' --numeric-owner
rm -f stage3-*
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'
  1. 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"

- edit /etc/resolv.conf as

nameserver 8.8.8.8 nameserver 8.8.4.4 ``

ping google.com
  1. copy the saved
cp -rfav /opt/orangepi5+-backup/modules lib/
cp -rfav /opt/orangepi5+-backup/firmware lib/
cp -rfav /opt/orangepi5+-backup/fstab /etc
  1. reset root password, no passwd
# sed -i 's/^root:.*/root::::::::/' /etc/shadow
  1. exit and boot

  2. 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:

  1. 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

  1. 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"

  1. Install portage

mkdir -p /etc/portage/repos.conf cp -f /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf emerge-webrsync

  1. 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.

  1. 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.