TELEMETRÍA (el pedido): el rootfs de la imagen es un initramfs = RAM pura y los logs iban a /run (tmpfs) ⇒ al apagar la máquina ajena no sobrevivía NADA. Ahora la imagen lleva 2da partición FAT32 MIRADALOG (512M), montada por findfs+LABEL con -o sync (un cuelgue de GPU o corte de luz no se lleva los logs). Cada arranque vuelca run-NNNN/ con: resumen (modo/GPU/driver), hardware (PCI vía sysfs, módulos, DRM, input, firmware), pantallas (status/modes por conector), dmesg ANTES y DESPUÉS de mirada, seatd, y el log del compositor+greeter con RUST_LOG=wgpu_core=debug + EGL_LOG_LEVEL=debug + LIBGL_DEBUG=verbose (para ver por qué wgpu eligió el backend y si hay float16). Shell de rescate + . FAT32 a propósito: el pendrive se lee después desde cualquier SO. metal-usb-sdboot.sh gana DATA_MB/DATA_LABEL genéricos (partición de datos opcional en la GPT). GOTCHAs verificados antes de confiar: el kernel linux-generic SÍ trae VFAT_FS=y + NLS + USB_STORAGE=y (sin eso no montaba); el busybox de Alpine NO trae el applet 00:00.0 Host bridge: Intel Corporation Tiger Lake-UP3/H35 4 cores Host Bridge/DRAM Registers (rev 01) 00:02.0 VGA compatible controller: Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics] (rev 01) 00:04.0 Signal processing controller: Intel Corporation TigerLake-LP Dynamic Tuning Processor Participant (rev 01) 00:07.0 PCI bridge: Intel Corporation Tiger Lake-LP Thunderbolt 4 PCI Express Root Port #0 (rev 01) 00:08.0 System peripheral: Intel Corporation GNA Scoring Accelerator module (rev 01) 00:0a.0 Signal processing controller: Intel Corporation Tigerlake Telemetry Aggregator Driver (rev 01) 00:0d.0 USB controller: Intel Corporation Tiger Lake-LP Thunderbolt 4 USB Controller (rev 01) 00:0d.2 USB controller: Intel Corporation Tiger Lake-LP Thunderbolt 4 NHI #0 (rev 01) 00:12.0 Serial controller: Intel Corporation 500 Series Chipset Family On-Package Integrated Sensor Hub (rev 20) 00:14.0 USB controller: Intel Corporation 500 Series Chipset Family On-Package USB 3.2 Gen 2x1 (10 Gbs) xHCI Host Controller (rev 20) 00:14.2 RAM memory: Intel Corporation 500 Series Chipset Family On-Package Shared SRAM (rev 20) 00:14.3 Network controller: Intel Corporation Wi-Fi 6 AX201 (rev 20) 00:15.0 Serial bus controller: Intel Corporation 500 Series Chipset Family On-Package I2C Controller #0 (rev 20) 00:15.1 Serial bus controller: Intel Corporation 500 Series Chipset Family On-Package I2C Controller #1 (rev 20) 00:16.0 Communication controller: Intel Corporation 500 Series Chipset Family On-Package CSME HECI #1 (rev 20) 00:1c.0 PCI bridge: Intel Corporation 500 Series Chipset Family On-Package PCI Express Root Port #5 (rev 20) 00:1d.0 PCI bridge: Intel Corporation 500 Series Chipset Family On-Package PCI Express Root Port #9 (rev 20) 00:1f.0 ISA bridge: Intel Corporation 500 Series Chipset Family On-Package eSPI Controller (rev 20) 00:1f.3 Multimedia audio controller: Intel Corporation 500 Series Chipset Family On-Package High Definition Audio (HD Audio) (rev 20) 00:1f.4 SMBus: Intel Corporation 500 Series Chipset Family On-Package System Management Bus (SMBus) (rev 20) 00:1f.5 Serial bus controller: Intel Corporation 500 Series Chipset Family On-Package SPI (flash) Controller (rev 20) 39:00.0 Non-Volatile memory controller: Kingston Technology Company, Inc. NV2 NVMe SSD [SM2267XT] (DRAM-less) (rev 03) 3a:00.0 Non-Volatile memory controller: ADATA Technology Co., Ltd. IM2P33F3 NVMe SSD (DRAM-less) (rev 03) (sí findfs/blkid) ⇒ el dump de PCI lee /sys/bus/pci/devices/*/ directo; sintaxis del init validada con busybox ash (no bash). BUMP mirada: el pin era 9967b02c (18-jun) — 439 commits viejo. Ahora 9a17fefc, que incluye el fix de portabilidad a musl que hice en tawasuyu (ioctl: glibc usa c_ulong, musl c_int ⇒ las constantes DRM casteaban mal y mirada-compositor NO compilaba para musl). mirada-compositor ya selló (87ced528); greeter/ctl en curso. + scripts/kde/{metal-desktop-image,plasma-start-metal}.sh del hilo KDE (imagen de escritorio en metal). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
107 lines
6.2 KiB
Bash
Executable File
107 lines
6.2 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# metal-usb-sdboot.sh — USB raw (GPT + ESP FAT32) que arranca hammer en metal vía systemd-boot.
|
|
#
|
|
# Alternativa de BRINGUP al boot por EFI-stub directo (que en el firmware del usuario se cuelga tras
|
|
# 'Measured initrd PCR 9', por el quirk de LoadOptions del firmware). systemd-boot:
|
|
# - pasa una cmdline LIMPIA al kernel (esquiva el quirk EFI_LOAD_OPTION del firmware),
|
|
# - provee el initrd por LoadFile2 (sin depender del initrd= de la cmdline),
|
|
# - permite EDITAR la cmdline en vivo (tecla 'e' en el menú) ⇒ iterar sin recompilar.
|
|
#
|
|
# ⚠️ systemd-bootx64.efi es un BINARIO AJENO (del host) — crutch de bringup. TODO: loader soberano.
|
|
#
|
|
# Salida: una IMAGEN DE DISCO (no ISO) para dd directo al pendrive:
|
|
# sudo dd if=work/hammer-metal-usb.img of=/dev/sdX bs=4M oflag=sync status=progress
|
|
#
|
|
# Uso: scripts/metal-usb-sdboot.sh
|
|
# Vars: ROOTFS (def work/metal-rootfs) KERNEL (def store/*-linux-metal más reciente)
|
|
# SDBOOT (def systemd-bootx64.efi del host) IMG (def work/hammer-metal-usb.img)
|
|
# OPTIONS (cmdline del loader entry)
|
|
set -eu
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
|
|
|
|
ROOTFS="${ROOTFS:-work/metal-rootfs}"
|
|
[ -d "$ROOTFS" ] || { echo "no existe ROOTFS=$ROOTFS (corré scripts/metal-iso.sh primero)" >&2; exit 1; }
|
|
KERNEL="${KERNEL:-$(ls -dt store/*-linux-metal/boot/bzImage 2>/dev/null | head -1)}"
|
|
[ -n "${KERNEL:-}" ] && [ -r "$KERNEL" ] || { echo "no encuentro kernel metal" >&2; exit 1; }
|
|
SDBOOT="${SDBOOT:-/home/sergio/.local/share/shuma/rootfs/arch/usr/lib/systemd/boot/efi/systemd-bootx64.efi}"
|
|
[ -r "$SDBOOT" ] || { echo "no encuentro systemd-bootx64.efi en $SDBOOT" >&2; exit 1; }
|
|
MT=$(ls -d store/*-mtools/usr/bin 2>/dev/null | head -1)
|
|
[ -n "$MT" ] && [ -x "$MT/mformat" ] || { echo "no encuentro mtools de hammer (build recipes/mtools.toml)" >&2; exit 1; }
|
|
IMG="${IMG:-work/hammer-metal-usb.img}"
|
|
# /dev/console=tty0 al FINAL ⇒ la getty de arje da shell en la PANTALLA. earlyprintk=efi para diagnóstico.
|
|
OPTIONS="${OPTIONS:-earlyprintk=efi,keep ignore_loglevel efi=novamap console=ttyS0,115200 console=tty0}"
|
|
WORK="$ROOT/work/metal-sdboot"; rm -rf "$WORK"; mkdir -p "$WORK"
|
|
|
|
echo "==> kernel: $KERNEL"
|
|
echo "==> rootfs: $ROOTFS ($(du -sh "$ROOTFS" | cut -f1))"
|
|
|
|
# 1) staging del initramfs: hardlinks del rootfs + /init del medio live (rdinit=/init lo corre)
|
|
echo "==> staging initramfs (+ /init marcador live)"
|
|
STG="$WORK/rfs"; cp -al "$ROOTFS" "$STG"
|
|
cat > "$STG/init" <<'INIT'
|
|
#!/bin/sh
|
|
/bin/busybox mount -t proc proc /proc 2>/dev/null || true
|
|
/bin/busybox mount -t sysfs sys /sys 2>/dev/null || true
|
|
/bin/busybox mount -t devtmpfs dev /dev 2>/dev/null || true
|
|
echo "HAMMER-METAL-LIVE-OK: arranque por systemd-boot"
|
|
exec /sbin/init
|
|
INIT
|
|
chmod +x "$STG/init"
|
|
|
|
# 2) empaquetar initramfs.cpio.gz (root-owned, igual que iso-image.sh)
|
|
echo "==> empaquetando initramfs.cpio.gz"
|
|
( cd "$STG" && find . -print0 | cpio --null -o -H newc -R 0:0 2>/dev/null | gzip -1 ) > "$WORK/initramfs.cpio.gz"
|
|
IRD="$WORK/initramfs.cpio.gz"; echo " initramfs: $(du -h "$IRD" | cut -f1)"
|
|
|
|
# 3) ESP FAT32: BOOTX64.EFI=systemd-boot + loader.conf + entry + kernel + initrd
|
|
espkb=$(( ( $(stat -c%s "$KERNEL") + $(stat -c%s "$IRD") ) / 1024 + 16384 ))
|
|
# FAT32 (-F) exige ~33 MiB mínimos; con initramfs chico (bisección) la ESP cae por debajo y la firmware
|
|
# no la lee ("Not Found"). Piso de 48 MiB para que el FAT32 siempre sea válido.
|
|
[ "$espkb" -lt 49152 ] && espkb=49152
|
|
ESP="$WORK/esp.img"; rm -f "$ESP"; truncate -s "$(( espkb * 1024 ))" "$ESP"
|
|
"$MT/mformat" -F -v HAMMER -i "$ESP" ::
|
|
"$MT/mmd" -i "$ESP" ::/EFI ::/EFI/BOOT ::/loader ::/loader/entries
|
|
"$MT/mcopy" -i "$ESP" "$SDBOOT" ::/EFI/BOOT/BOOTX64.EFI
|
|
printf 'default hammer\ntimeout 8\neditor yes\n' > "$WORK/loader.conf"
|
|
printf 'title hammer (metal)\nlinux /bzImage\ninitrd /initramfs.cpio.gz\noptions %s\n' "$OPTIONS" > "$WORK/hammer.conf"
|
|
"$MT/mcopy" -i "$ESP" "$WORK/loader.conf" ::/loader/loader.conf
|
|
"$MT/mcopy" -i "$ESP" "$WORK/hammer.conf" ::/loader/entries/hammer.conf
|
|
"$MT/mcopy" -i "$ESP" "$KERNEL" ::/bzImage
|
|
"$MT/mcopy" -i "$ESP" "$IRD" ::/initramfs.cpio.gz
|
|
echo "==> ESP poblada ($(du -h "$ESP" | cut -f1)):"
|
|
"$MT/mdir" -i "$ESP" ::/ ::/EFI/BOOT ::/loader/entries 2>/dev/null | grep -iE 'BOOTX64|bzImage|initram|hammer|loader' || true
|
|
|
|
# 4) imagen de disco GPT: GPT primaria (1MiB) + ESP (en sector 2048) + GPT backup
|
|
esp_sectors=$(( espkb * 2 )) # KiB→sectores de 512
|
|
|
|
# Partición de DATOS opcional (DATA_MB>0): FAT32 con etiqueta, para que el sistema live escriba ahí lo
|
|
# que deba SOBREVIVIR al apagado (telemetría/logs). El rootfs de esta imagen es un initramfs = RAM pura:
|
|
# sin esta partición NO queda rastro de nada al cortar la luz. FAT32 (no ext4) a propósito: el pendrive
|
|
# se lee después desde CUALQUIER máquina (Windows/Mac/Linux) sin herramientas.
|
|
DATA_MB="${DATA_MB:-0}"
|
|
DATA_LABEL="${DATA_LABEL:-HAMMERLOG}"
|
|
data_sectors=0
|
|
if [ "$DATA_MB" -gt 0 ]; then
|
|
DATA="$WORK/data.img"; rm -f "$DATA"; truncate -s "$(( DATA_MB * 1024 * 1024 ))" "$DATA"
|
|
"$MT/mformat" -F -v "$DATA_LABEL" -i "$DATA" ::
|
|
data_sectors=$(( DATA_MB * 2048 ))
|
|
echo "==> partición de datos FAT32 ${DATA_MB}M etiqueta=$DATA_LABEL (telemetría persistente)"
|
|
fi
|
|
|
|
rm -f "$IMG"; truncate -s "$(( (2048 + esp_sectors + data_sectors + 2048) * 512 ))" "$IMG"
|
|
{
|
|
echo "label: gpt"
|
|
echo "start=2048, size=$esp_sectors, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, name=\"EFI System Partition\""
|
|
[ "$data_sectors" -gt 0 ] && \
|
|
echo "start=$(( 2048 + esp_sectors )), size=$data_sectors, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, name=\"$DATA_LABEL\""
|
|
} | sfdisk --quiet "$IMG"
|
|
dd if="$ESP" of="$IMG" bs=512 seek=2048 conv=notrunc status=none
|
|
[ "$data_sectors" -gt 0 ] && dd if="$DATA" of="$IMG" bs=512 seek=$(( 2048 + esp_sectors )) conv=notrunc status=none
|
|
|
|
echo
|
|
echo "✓ USB metal (systemd-boot): $IMG ($(du -h "$IMG" | cut -f1))"
|
|
[ "$data_sectors" -gt 0 ] && echo " + partición $DATA_LABEL (FAT32 ${DATA_MB}M) para telemetría — legible en cualquier SO"
|
|
echo " Quemar: sudo dd if=$IMG of=/dev/sdX bs=4M oflag=sync status=progress"
|
|
echo " Bootear: el menú de systemd-boot aparece; ENTER arranca. Tecla 'e' = EDITAR la cmdline en vivo."
|
|
echo " Secure Boot OFF. WiFi (en consola): wifi-connect \"SSID\" \"CLAVE\""
|