fix(init): el reboot-loop de Fedora — remount rw + /run tmpfs + shell de rescate

Diagnóstico: en el VPS Fedora arje-zero caía como PID 1 y el cmdline
traía `panic=10`, así que el kernel rebooteaba cada 10 s. Tres causas
encadenadas, todas arregladas:

1) **Cmdline `ro` + sin `/run` tmpfs.** El menuentry montaba `/` como
   sólo lectura (systemd lo remonta rw temprano; arje no). Sin eso, el
   socket del bus interno se intenta crear sobre un FS de sólo lectura
   y falla con EROFS → spawn_bus devuelve Err → PID 1 sale → kernel
   panic. arje-kernel ahora remonta `/` rw en el bootstrap y monta
   `/run`, `/tmp`, `/dev/pts`, `/dev/shm` como tmpfs — superficies
   escribibles aunque la raíz quede ro.

2) **PID 1 saliendo en cualquier `?`.** Doctrina dura nueva: PID 1
   NUNCA puede salir. Cualquier error de arranque ahora cae a una
   `emergency_shell()` que imprime el diagnóstico en `/dev/console`,
   abre `/bin/sh` y, si la shell muere, la reabre — así el operador
   puede reparar en vez de mirar la máquina reiniciarse en bucle.

3) **El script no conocía grub2 (Fedora).** `install-arje-as-init.sh`
   sólo probaba `update-grub` (Debian) y `grub-mkconfig` (Arch). Ahora
   detecta `grub2-mkconfig` y resuelve el `grub.cfg` correcto
   (UEFI/BIOS, fedora/redhat/centos/almalinux/rocky). El menuentry
   también pasa de `ro` a `rw` — el remount es belt-and-suspenders.
   Mismo arreglo en `uninstall-arje.sh`.

Renaser intacto: estos cambios son Linux-side puro (arje-kernel y
arje-zero usan nix/libc/tracing); renaser sólo comparte mirada-layout y
formato, ninguno tocado.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-22 23:02:45 +00:00
parent 922ad1f86b
commit d1b700eb2b
4 changed files with 185 additions and 32 deletions
+27 -6
View File
@@ -133,23 +133,44 @@ menuentry "arje (init=/sbin/arje-zero) — kernel $KVER" {
insmod gzio
insmod part_msdos
insmod ext2
linux $VMLINUZ $ROOT_OPT ro init=/sbin/arje-zero console=tty1 console=ttyS0,115200 panic=10
linux $VMLINUZ $ROOT_OPT rw init=/sbin/arje-zero console=tty1 console=ttyS0,115200 panic=10
initrd $INITRD
}
# END ARJE-MENUENTRY
EOF
chmod 0755 "$CUSTOM"
# Regenerar grub.cfg.
# Regenerar grub.cfg. Detectamos la convención de la distro: Debian /
# Ubuntu usan `update-grub` (wrapper de grub-mkconfig). Fedora / RHEL /
# CentOS usan `grub2-mkconfig` y el .cfg vive en /boot/grub2/ (BIOS) o
# /boot/efi/EFI/<distro>/ (UEFI). Arch usa `grub-mkconfig`.
if command -v update-grub >/dev/null 2>&1; then
echo " ejecutando update-grub"
echo " ejecutando update-grub (Debian/Ubuntu)"
update-grub
elif command -v grub2-mkconfig >/dev/null 2>&1; then
# Fedora / RHEL: buscar el grub.cfg activo. UEFI primero — su path es
# el que arranca realmente; el de BIOS suele ser un symlink al UEFI.
GRUB_CFG=""
for cand in /boot/efi/EFI/fedora/grub.cfg \
/boot/efi/EFI/redhat/grub.cfg \
/boot/efi/EFI/centos/grub.cfg \
/boot/efi/EFI/almalinux/grub.cfg \
/boot/efi/EFI/rocky/grub.cfg \
/boot/grub2/grub.cfg; do
if [ -f "$cand" ] || [ -L "$cand" ]; then GRUB_CFG="$cand"; break; fi
done
if [ -z "$GRUB_CFG" ]; then
GRUB_CFG="/boot/grub2/grub.cfg"
echo " no detecté grub.cfg existente — usando $GRUB_CFG por default"
fi
echo " ejecutando grub2-mkconfig -o $GRUB_CFG (Fedora/RHEL)"
grub2-mkconfig -o "$GRUB_CFG"
elif command -v grub-mkconfig >/dev/null 2>&1; then
echo " ejecutando grub-mkconfig"
echo " ejecutando grub-mkconfig (Arch/otros)"
grub-mkconfig -o /boot/grub/grub.cfg
else
echo "[install-arje] WARN: no encontré update-grub ni grub-mkconfig." >&2
echo " Regenerá grub.cfg manualmente." >&2
echo "[install-arje] WARN: no encontré update-grub, grub2-mkconfig ni grub-mkconfig." >&2
echo " Regenerá la grub.cfg manualmente." >&2
fi
cat <<EOF
+11
View File
@@ -38,6 +38,17 @@ fi
if command -v update-grub >/dev/null 2>&1; then
update-grub
elif command -v grub2-mkconfig >/dev/null 2>&1; then
GRUB_CFG=""
for cand in /boot/efi/EFI/fedora/grub.cfg \
/boot/efi/EFI/redhat/grub.cfg \
/boot/efi/EFI/centos/grub.cfg \
/boot/efi/EFI/almalinux/grub.cfg \
/boot/efi/EFI/rocky/grub.cfg \
/boot/grub2/grub.cfg; do
if [ -f "$cand" ] || [ -L "$cand" ]; then GRUB_CFG="$cand"; break; fi
done
grub2-mkconfig -o "${GRUB_CFG:-/boot/grub2/grub.cfg}"
elif command -v grub-mkconfig >/dev/null 2>&1; then
grub-mkconfig -o /boot/grub/grub.cfg
fi