Skip to content

Instantly share code, notes, and snippets.

@c0m4r
Last active January 24, 2024 22:30
Show Gist options
  • Save c0m4r/0eaf45b66623f0885232f5e07656c14d to your computer and use it in GitHub Desktop.
Save c0m4r/0eaf45b66623f0885232f5e07656c14d to your computer and use it in GitHub Desktop.
Gentoo ARM64 IPv6 installation on Hetzner Cloud VPS

Gentoo ARM64 IPv6 quick-ish setup on Hetzner Cloud

image

This guide explains how to waste your time installing Gentoo on a Hetzner Cloud VPS.

Not only that, I use IPv6-only connected machine and Arm64 at the same time. If I'm not insane, I don't know who is.

Also, yes, I'm skipping lots of configuration steps.

Gentoo fanboys will send me death threats love letters after reading this...

YOLO 🥳

Hetzner Rescue

Tested on CAX31 (8 x Ampere vCPU arm64) with Ubuntu installed as a default (but you can choose any, it doesn't matter).

This haunted system compiles everything, so if you want to use a smaller VM, say CAX11, choose it first, scale it to a higher one for the installation (RAM & CPU only), so that you can downgrade it after installation. You're paying by per hour basis anyway.

First log into Hetzner Cloud, switch to your VPS control panel, select Rescue -> Enable Rescue and Power Cycle. It takes up to 1 minute to boot into rescue mode. Your login details will be displayed in the control panel after you activate the console. You can also use previously defined SSH keys.

Dreaded dragons 🦄

Log into the rescue SSH and follow all the steps.

Let's take a look at the available drives.

fdisk -l

Disk /dev/sda: 152.59 GiB, 163842097152 bytes, 320004096 sectors
Disk model: QEMU HARDDISK   
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: gpt
Disk identifier: 021DD254-6352-4162-9F6A-75DA1EB5B9AB

Device      Start     End Sectors  Size Type
/dev/sda1  528384 9213951 8685568  4.1G Linux filesystem
/dev/sda14   2048    4095    2048    1M BIOS boot
/dev/sda15   4096  528383  524288  256M EFI System

Leave the partitions alone (or not, it's up to you, I don't mind, nor care).

But seriously, leave them be.

FOR THE LOVE OF GOD, STOP WIPING THESE PARTITIONS

Hmm...

Actually, you know what?

Let's wipe them... 🤔

wipefs -a /dev/sda
parted /dev/sda --script "mklabel gpt"
parted /dev/sda --script "mkpart primary 1 3"
parted /dev/sda --script "set 1 bios_grub on"
parted /dev/sda --script "mkpart primary 3 100"
parted /dev/sda --script "set 2 boot on"
parted /dev/sda --script "mkpart primary 100 -1"
mkfs.vfat /dev/sda2
mkfs.ext4 /dev/sda3
mkdir /mnt/gentoo
mount /dev/sda3 /mnt/gentoo

Next, you need a tarball called stage3. Don't ask me, stage3, whatever.

I have no idea where the other two are. Just get the stage3 and stop whining.

Look for one (I mean three) at:

I use the OpenRC version, not the other one. The other one is 💩, not mentioning its creator. The other one is like an uninvited guest. It comes to you, it's loud, it's rampant, and you want to get rid of it as quickly as possible. But you can't get rid of it because it's everywhere. So you start drinking, your girlfriend leaves you, you lose your job and no one wants to talk to you. And you like to talk. And the girlfriend was pretty. Gosh, you had a great job. In other words, don't install the other one.

We're about to deploy the stage3 tarball, set up the network, mount everything and enter chroot.

cd /mnt/gentoo
wget https://packages.hetzner.com/gentoo/releases/arm64/autobuilds/20240114T224835Z/stage3-arm64-openrc-20240114T224835Z.tar.xz
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
rm stage3-arm64-openrc-20240114T224835Z.tar.xz
cp /etc/resolv.conf /mnt/gentoo/etc/
cat <<EOF > /mnt/gentoo/etc/conf.d/net
modules="iproute2"

config_eth0="
	$(ip a s | grep "::1\/64" | awk '{print $2}')
"

routes_eth0="
	default via fe80::1

"
dns_servers_eth0="
	2606:4700:4700::1111
	2606:4700:4700::1001
	2620:fe::fe
"
EOF
cd ..
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
mount --make-slave /mnt/gentoo/run
chroot /mnt/gentoo /bin/bash

I have no idea what I'm doing

image

Next, we're going to deploy some package manager configuration, set the timezone and locales.

mkdir /etc/portage/repos.conf
cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf
sed -i 's/rsync.gentoo.org/mirror.netcologne.de/g;' /etc/portage/repos.conf/gentoo.conf
echo "MAKEOPTS=\"-j$(nproc)\"" >> /etc/portage/make.conf
echo "USE=ipv6" >> /etc/portage/make.conf
emerge-webrsync
eselect profile set 1
echo "Europe/Warsaw" > /etc/timezone
emerge --config sys-libs/timezone-data
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
locale-gen
eselect locale set 3

Questioning the meaning of life

There's no GNU/Linux without Linux. Ok, there's GNU Hurd but who cares.

Besides, then it would be GNU/GNU Hurd, or maybe Hurr Durr GNU? I don't know...

Aynway, we need to install the linux kernel.

The next steps take like forever so do yourself a drink or something. I don't know, read a book, watch a documentary about ancient aliens, just don't complain, ok? But the title said "quick setup". Yeah, and my ex said she's emotionally stable. What to do? I know it's bullshit, but it wasn't my idea, blame gentoo guys, I'm just a messenger.

emerge sys-kernel/installkernel
emerge sys-kernel/gentoo-kernel-bin
emerge --depclean
emerge --ask @module-rebuild
eselect kernel set 1

I don't know what they did to this poor distro but it takes like freaking hundred times more to install than ANY other distro. I could've installed like 10 of them already, and on a calculator. I don't know what made me install the damn gentoo. I guess I don't value my time ¯\(ツ)/¯. But seriously, it's 8 core ARM and I feel like it was 1997. Apparently gentoo users are masochists. I bet they whip themselves with a twisted pair cable every morning. And they sleep on unsoldered PCI slots scattered on the floor.

Ok, so maybe some knock knock joke.

Knock knock.
Who’s there?
SYN flood.
SYN flood who?
Knock knock.…

Done already? Ok, carry on:

Now you need to create /etc/fstab. Use blkid to find out the UUIDs of the EFI and rootfs partitions and set them up accordingly.

Here's the dirty way:

echo UUID=\"$(blkid /dev/sda3 | grep -oP UUID.* | cut -f2 -d\")\" / ext4 relatime 0 1 >> /etc/fstab
echo UUID=\"$(blkid /dev/sda2 | grep -oP UUID.* | cut -f2 -d\")\" /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,error=remount-ro 0 2 >> /etc/fstab

Aren't you tired already?

Ok, let's waste some more time.

passwd
rc-update add sshd default
echo "sys-kernel/installkernel grub" > /etc/portage/package.use/grub
emerge sys-boot/grub
emerge sys-boot/efibootmgr
mkdir /boot/efi
mount -t vfat /dev/sda2 /boot/efi
echo 'efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0' >> /etc/fstab
mount -v efivarfs
grub-install /dev/sda
sed -i 's/#GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="console=tty1 net.ifnames=0"/g;' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
emerge net-misc/netifrc
ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
rc-update add net.eth0
exit

Let the world burn 🔥

image

Being like twelve hours older, and leaving the carbon footprint of the Boeing 777 after all these pointlessly compiled packages, you can finally run Gentoo.

cp -r /root/.ssh /mnt/gentoo/root/
rm -f /mnt/gentoo/root/.ssh/robot_user_keys
reboot

But if I were you I'd go back to wipefs -a /dev/sda and install Arch 🤭


If you found this article helpful, please consider making a donation to a charity on my behalf. Thank you.

If it is not apparent enough, I would like to emphasize that this guide was created for humorous purposes and is not intended to offend anyone. Although it's a bit tempting, at least in some cases 🙃

Yet, if my rants about Gentoo pissed you off (the pleasure is all mine), feel free to insult me in the comments. However, keep in mind that I'm just kidding, and in favor of Gentoo, I will say that Guix is even worse :D

Image sources:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment