Initial commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Partition DISK: GPT, 512M EFI + rest ext4 root. Mounts root at /mnt, ESP at /mnt/boot.
|
||||
# Sourced by run.sh (DISK comes from system.conf).
|
||||
|
||||
part() { case "$DISK" in *nvme*|*mmcblk*) echo "${DISK}p$1" ;; *) echo "${DISK}$1" ;; esac; }
|
||||
EFI="$(part 1)"; ROOT="$(part 2)"
|
||||
|
||||
info "partitioning $DISK"
|
||||
sgdisk --zap-all "$DISK"
|
||||
sgdisk -n1:0:+512M -t1:ef00 -c1:EFI "$DISK"
|
||||
sgdisk -n2:0:0 -t2:8300 -c2:root "$DISK"
|
||||
partprobe "$DISK"; sleep 1
|
||||
|
||||
mkfs.fat -F32 "$EFI"
|
||||
mkfs.ext4 -F "$ROOT"
|
||||
|
||||
mount "$ROOT" /mnt
|
||||
mount --mkdir "$EFI" /mnt/boot # ESP at /boot so the kernel + initramfs land on it
|
||||
@@ -0,0 +1,12 @@
|
||||
# Install a minimal base system, generate fstab, copy this repo into the new root.
|
||||
# Sourced by run.sh. The FULL package set is installed later by 02-system/run.sh.
|
||||
|
||||
pacstrap -K /mnt \
|
||||
base linux linux-firmware intel-ucode amd-ucode \
|
||||
mkinitcpio networkmanager sudo git base-devel vim efibootmgr terminus-font
|
||||
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
||||
# carry the repo into the installed system so provisioning can run after reboot
|
||||
mkdir -p /mnt/root
|
||||
cp -a "$REPO_ROOT" /mnt/root/arch-system-th
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs INSIDE arch-chroot. systemd-boot + mkinitcpio with STATIC loader entries.
|
||||
# mkinitcpio already built /boot/initramfs-linux*.img during pacstrap, and its
|
||||
# pacman hooks rebuild them on every kernel update — nothing to regenerate here
|
||||
# or later. The kernel cmdline lives in the loader entry's `options` line.
|
||||
set -euo pipefail
|
||||
|
||||
bootctl install # ESP is mounted at /boot
|
||||
|
||||
ROOT_UUID="$(findmnt -no UUID /)"
|
||||
|
||||
# microcode image matching this CPU (both packages are installed)
|
||||
case "$(grep -m1 -oE 'Intel|AMD' /proc/cpuinfo)" in
|
||||
Intel) UCODE="initrd /intel-ucode.img" ;;
|
||||
AMD) UCODE="initrd /amd-ucode.img" ;;
|
||||
*) UCODE="" ;;
|
||||
esac
|
||||
|
||||
mkdir -p /boot/loader/entries
|
||||
|
||||
cat > /boot/loader/loader.conf <<EOF
|
||||
default arch.conf
|
||||
timeout 3
|
||||
console-mode keep
|
||||
EOF
|
||||
|
||||
cat > /boot/loader/entries/arch.conf <<EOF
|
||||
title Arch Linux
|
||||
linux /vmlinuz-linux
|
||||
$UCODE
|
||||
initrd /initramfs-linux.img
|
||||
options root=UUID=$ROOT_UUID rw
|
||||
EOF
|
||||
|
||||
cat > /boot/loader/entries/arch-fallback.conf <<EOF
|
||||
title Arch Linux (fallback initramfs)
|
||||
linux /vmlinuz-linux
|
||||
$UCODE
|
||||
initrd /initramfs-linux-fallback.img
|
||||
options root=UUID=$ROOT_UUID rw
|
||||
EOF
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs INSIDE arch-chroot. Locale, time, hostname, user, network.
|
||||
set -euo pipefail
|
||||
source /root/arch-system-th/system.conf
|
||||
|
||||
# time + locale
|
||||
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
|
||||
hwclock --systohc
|
||||
sed -i "s/^#\s*\($LOCALE\)/\1/" /etc/locale.gen
|
||||
locale-gen
|
||||
echo "LANG=$LOCALE" > /etc/locale.conf
|
||||
echo "KEYMAP=$KEYMAP" > /etc/vconsole.conf
|
||||
|
||||
# hostname
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
|
||||
# user + sudo (wheel)
|
||||
useradd -m -G wheel -s /bin/bash "$USERNAME" 2>/dev/null || true
|
||||
echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/10-wheel
|
||||
chmod 440 /etc/sudoers.d/10-wheel
|
||||
echo "Set passwords for root and $USERNAME:"
|
||||
passwd root
|
||||
passwd "$USERNAME"
|
||||
|
||||
# move the repo into the user's home so provisioning runs as them after reboot
|
||||
cp -a /root/arch-system-th "/home/$USERNAME/arch-system-th"
|
||||
chown -R "$USERNAME:$USERNAME" "/home/$USERNAME/arch-system-th"
|
||||
|
||||
# network up on first boot
|
||||
systemctl enable NetworkManager.service
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# Base Arch install, run from the live ISO (as root, UEFI).
|
||||
# Partitions DISK, installs a minimal base, sets up systemd-boot + mkinitcpio, then
|
||||
# hands off to the system + user provisioning layers after first boot.
|
||||
#
|
||||
# ./run.sh # reads ../system.conf
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
source ../02-system/lib.sh
|
||||
source ../system.conf
|
||||
REPO_ROOT="$(cd .. && pwd)"
|
||||
|
||||
# Safety net: if the repo arrived without exec bits (USB on exFAT, or the optional
|
||||
# custom ISO which strips modes), restore +x so the copies we propagate to the
|
||||
# installed system are runnable. Harmless when git already preserved them.
|
||||
find "$REPO_ROOT" -name '*.sh' -exec chmod +x {} + 2>/dev/null || true
|
||||
|
||||
[ "$(id -u)" -eq 0 ] || die "run as root from the live ISO"
|
||||
[ -d /sys/firmware/efi ] || die "not booted in UEFI mode"
|
||||
[ -b "$DISK" ] || die "DISK '$DISK' is not a block device — edit system.conf"
|
||||
|
||||
echo "About to ERASE $DISK and install Arch (host=$HOSTNAME user=$USERNAME)."
|
||||
read -rp "Type ERASE to continue: " ans
|
||||
[ "$ans" = ERASE ] || die "aborted"
|
||||
|
||||
source ./00-partition.sh # partitions + mounts /mnt, /mnt/boot
|
||||
source ./10-pacstrap.sh # base system + fstab + copy repo to /mnt/root
|
||||
|
||||
# in-chroot steps (the whole repo, incl. system.conf, was copied by 10-pacstrap)
|
||||
arch-chroot /mnt bash /root/arch-system-th/01-install/20-boot.sh
|
||||
arch-chroot /mnt bash /root/arch-system-th/01-install/30-finalize.sh
|
||||
|
||||
info "Base install done. Reboot, remove the ISO, then as your user run:"
|
||||
info " sudo ~/arch-system-th/02-system/run.sh"
|
||||
info " ~/arch-system-th/03-user/run.sh"
|
||||
Reference in New Issue
Block a user