From 4278a3198dc9e6750b0500e7f778102d38802491 Mon Sep 17 00:00:00 2001 From: N0VA Date: Thu, 5 Feb 2026 18:30:55 +0100 Subject: [PATCH] Add minimal-linux-installer skill with proven installation patterns --- minimal-linux-installer.skill | Bin 0 -> 1900 bytes minimal-linux-installer/SKILL.md | 120 +++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 minimal-linux-installer.skill create mode 100644 minimal-linux-installer/SKILL.md diff --git a/minimal-linux-installer.skill b/minimal-linux-installer.skill new file mode 100644 index 0000000000000000000000000000000000000000..78208adc926f237f23540ff266d3de3f872fed9c GIT binary patch literal 1900 zcmV-y2b1_8iwFP!000001MOH_Z`(!|_A`IQfzmA`SEOvmasZ<))@hx@Sf>f%8vD>1 z(uf>N1CtzWUm4UabO4ILa0k57+r8J?aT9O3a~ctFFisl-02U~xfokR8p%r}lkr z{r{BGJ^sJ_*Y(X!kVaoa20Qrd^mL#9pPiko{eSut?~jL1PtFeL=xYf79R1Dx@B6-& ziBz7`o=ET_X~II~rPA3sy{uFuDb@vrg%qXArc~$&Fzh$y>4wkK>b#-u3mNG`_!D7d z)T4zeXJnS9lxgHow8l{#$B-&1%3?BAp6dcHMHW#Z6D1~zq{>K$)LE>iRUufHfbNW> z#Y|>2sZ2+KuT$|5rsgq37xeBYt*2!uYFT!t!EA$~6jAvcv4y-jQ!Dkh-o62{IMJV0Oa zAripbP@*0rF=&Yv(Jmy^-GsHb#x)n=gP2N6MTT1{GY79lRfM6gvXYD}t2_WWPv}Qo zNcy)f9^ynV48M9p#{s<+MX6X2EB-CL=3{vDyu(9_8_POBJfzEHA(n=!EVYdD=9r<0 zjG1++BNZ>1OF5HiP;;W($STr)tP<&fpsvcoq_PN)Wvu3+h|RdyunA`c?8G9p9*@WQ zvYhD*&b@Pj1-ox8901k0Q>4s;Co@wOa^$p>QMXucO4IEOpz0u2MY=%14&bvv?KjiueO^_2 zZT!6RyrcA9F)#$NP{-^^KyO?MymcwyQr+dtPd~rtJqq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nKhS&LQX>9km)6Z6zZsWv^+~E4Z{y(6l mmRf45rIuQ1sil@$YN@4`T574KmRkDj(0>4rUnx%jC;$M6t;bma literal 0 HcmV?d00001 diff --git a/minimal-linux-installer/SKILL.md b/minimal-linux-installer/SKILL.md new file mode 100644 index 0000000..59ec020 --- /dev/null +++ b/minimal-linux-installer/SKILL.md @@ -0,0 +1,120 @@ +--- +name: minimal-linux-installer +description: Guide for creating robust, minimal Linux installers (Fedora-based) with systemd-boot, offline dnf support, and reliable user configuration. Use when building or debugging custom OS installers. +--- + +# Minimal Linux Installer Guide + +This skill provides proven patterns for building minimal, robust Linux installers, specifically targeting Fedora-based systems. It covers critical areas like bootloader configuration (systemd-boot), offline package management, and user account setup. + +## Core Workflows + +### 1. Partitioning & Mounting + +**Guideline:** Always unmount partitions before modifying them. Mount pseudo-filesystems (including `efivarfs`) before chrooting. + +```python +# Unmount all partitions on target disk +ensure_unmounted(target_disk) + +# ... Partitioning logic (EFI @ 512MB+, Root) ... + +# Mount pseudo-filesystems +def mount_pseudo_fs(mount_root): + mounts = ["dev", "proc", "sys"] + for fs in mounts: + run_command(["mount", "--bind", f"/{fs}", f"{mount_root}/{fs}"]) + + # Critical for UEFI variable updates + if os.path.exists("/sys/firmware/efi/efivars"): + run_command(["mount", "-t", "efivarfs", "efivarfs", f"{mount_root}/sys/firmware/efi/efivars"]) +``` + +### 2. Offline Package Installation (DNF) + +**Guideline:** Prioritize local ISO repositories to allow offline installation. Fallback to network only if necessary. + +```python +# Search for ISO repo in common live media locations +possible_repos = [ + "/run/install/repo", + "/run/install/source", + "/mnt/install/repo", + "/run/initramfs/live", + "/run/initramfs/isoscan" +] +# Also check /run/media/$USER/$LABEL + +iso_repo = find_repo(possible_repos) + +if iso_repo: + # Strict offline mode + dnf_args = [ + "--disablerepo=*", + f"--repofrompath=local-iso,{iso_repo}", + "--enablerepo=local-iso", + "--cacheonly" # Critical for dnf5 to avoid metadata download + ] +else: + # Network fallback + dnf_args = [] + +# Essential packages for a bootable minimal system +packages = [ + "basesystem", "bash", "coreutils", "kernel", "systemd", + "systemd-boot-unsigned", # Required for bootctl + "dnf", "shadow-utils", "util-linux", # User mgmt & utils + "efibootmgr", "passwd", "rootfiles", "vim-minimal" +] +``` + +### 3. Bootloader Configuration (systemd-boot) + +**Guideline:** Use `bootctl` and `kernel-install` for a robust, standardized boot process. Set layout to `bls`. + +```python +# 1. Configure kernel layout +with open(f"{mount_root}/etc/kernel/layout", "w") as f: + f.write("bls\n") + +# 2. Install bootloader +# Remove --force if not supported by target version +run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot"]) + +# 3. Generate initramfs if missing +if not os.path.exists(f"{mount_root}/boot/initramfs-{kver}.img"): + run_command(["chroot", mount_root, "dracut", "--force", f"/boot/initramfs-{kver}.img", kver]) + +# 4. Add kernel entry +# kernel-install add +run_command(["chroot", mount_root, "kernel-install", "add", kver, kernel_image, initrd_path]) +``` + +### 4. Reliable User & Password Setup + +**Guideline:** Avoid piping plaintext passwords to stdin of `chpasswd` inside chroot if possible. Pre-hash passwords on the host or use `usermod -p`. + +```python +# 1. Create User +run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", username]) + +# 2. Hash Password (Host-side) +# openssl passwd -6 generates SHA512 hash +hash = subprocess.check_output(["openssl", "passwd", "-6", password], text=True).strip() + +# 3. Set Password (Directly modify shadow via usermod) +run_command(["chroot", mount_root, "usermod", "-p", hash, username]) +run_command(["chroot", mount_root, "usermod", "-p", hash, "root"]) + +# 4. Ensure Sudo Access +with open(f"{mount_root}/etc/sudoers.d/wheel", "w") as f: + f.write("%wheel ALL=(ALL) ALL\n") +``` + +### 5. Finalization + +**Guideline:** Always `sync` to flush write buffers to physical media. + +```python +run_command(["sync"]) +``` \ No newline at end of file