EndPointCorp / end-point-blog

End Point Dev blog
https://www.endpointdev.com/blog/
17 stars 65 forks source link

Comments for Rocky Linux 9 at Hetzner Robot for the impatient #1982

Open sethjensen1 opened 1 year ago

sethjensen1 commented 1 year ago

Comments for https://www.endpointdev.com/blog/2023/06/rocky-linux-9-at-hetzner-robot-for-the-impatient/ by Jeffry Johar

To enter a comment:

  1. Log in to GitHub
  2. Leave a comment on this issue.
brianclemens commented 1 year ago

Hi, Rocky Linux project manager here. Please don't do this (upgrade from 8 to 9 by swapping the version in the repos), it results in a potentially broken, unsupported system. A better solution is to make use of Hetzner Robot's recovery system, which is what I use to provision my Rocky Linux systems there.

The basic idea is to boot the machine to recovery from the robot console, wipe everything, throw a kernel, ramdisk, and kickstart in there, install grub and point it at them, reboot and let the kickstart rip.

I've included some bits from the ansible playbook I use to do this, minus the kickstart because I'm too lazy to sanitize that right now. I could probably automate the Robot console "reboot to recovery" bit too but right now I just manually do that before running the playbook.

Variables

rocky__version: 9
rocky__install_dev: nvme0n1
rocky__boot_dev: nvme0n1p1

Install script

#!/bin/bash

set -e

MIRROR=https://mirror.hetzner.de/rockylinux/{{ rocky__version }}/BaseOS/x86_64/os

### Wipe all partitions on the existing disk
wipefs --all --force /dev/{{ rocky__install_dev }}
wipefs --all --force /dev/nvme1n1

### Create and partition to allow kickstarts
parted -s /dev/{{ rocky__install_dev }} mklabel msdos
parted -s /dev/{{ rocky__install_dev }} mkpart primary 4M 200M
mkfs.ext4 -q -L OEMDRV /dev/{{ rocky__boot_dev }}
mount /dev/{{ rocky__boot_dev }} /boot

### Download kernel and installer initrd to kickstart partition
curl -o /boot/vmlinuz $MIRROR/isolinux/vmlinuz
curl -o /boot/initrd.img $MIRROR/isolinux/initrd.img

### Install and configure Grub to load the installer initrd
apt install -y grub-pc-bin
grub-install --boot-directory=/boot /dev/{{ rocky__install_dev }}
cat >/boot/grub/grub.cfg <<EOF
set default=0
set timeout=5
menuentry "Rocky Linux Kickstart" {
set root=(hd0,1)
linux /vmlinuz
initrd /initrd.img
}
EOF

Tasks

---
- name: Upload kickstart preparation script
  ansible.builtin.template:
    src: prepare-kickstart.sh.j2
    dest: /root/prepare-kickstart.sh
    mode: '0755'

- name: Run kickstart preparation script
  command: /bin/bash /root/prepare-kickstart.sh

- name: Upload kickstart
  ansible.builtin.template:
    src: ks.cfg.j2
    dest: /boot/ks.cfg
    mode: '0644'

# Use reboot with ignore errors because it's not coming back
- name: Reboot to installer
  command: reboot
  ignore_errors: yes
aburayyanjeffry commented 1 year ago

Hi @brianclemens , thanks for the input. You solution looks very solid.

aburayyanjeffry commented 1 year ago

Hi @brianclemens , I've tried to the kickstart as you said but without the ansible. I can't seems to make it bootable to grub and the kickstart.

grub-install seems ok but Hetzner won't boot the disk

root@rescue ~ # lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0    3G  1 loop
nvme3n1     259:0    0  1.7T  0 disk
nvme1n1     259:1    0  1.7T  0 disk
nvme0n1     259:2    0  1.7T  0 disk
└─nvme0n1p1 259:5    0  187M  0 part /boot
nvme2n1     259:3    0  1.7T  0 disk
root@rescue ~ # file -s /dev/nvme0n1
/dev/nvme0n1: DOS/MBR boot sector
samuelmf commented 1 year ago

Good tuto, can i use the same for Almalinux 9.1? I have the same "We do not yet support almalinux 91"