Skip to content

Instantly share code, notes, and snippets.

@fourcolors
Last active February 21, 2026 08:18
Show Gist options
  • Select an option

  • Save fourcolors/a165ec659149badb0e882e4e65a6e3bf to your computer and use it in GitHub Desktop.

Select an option

Save fourcolors/a165ec659149badb0e882e4e65a6e3bf to your computer and use it in GitHub Desktop.
T2 Mac Arch Linux server setup script
#!/bin/bash
set -e
echo "=== T2 Arch Server - Full Install Script ==="
echo "This will WIPE /dev/nvme0n1 completely!"
echo ""
read -p "Press Enter to continue or Ctrl+C to abort..."
# Unmount anything leftover
umount -R /mnt 2>/dev/null || true
swapoff -a 2>/dev/null || true
# Partition: 1G EFI, 8G swap, rest ext4
echo "=== Partitioning ==="
sgdisk -Z /dev/nvme0n1
sgdisk -n 1:0:+1G -t 1:ef00 /dev/nvme0n1
sgdisk -n 2:0:+8G -t 2:8200 /dev/nvme0n1
sgdisk -n 3:0:0 -t 3:8300 /dev/nvme0n1
echo "[OK] Partitioned"
# Format
echo "=== Formatting ==="
mkfs.fat -F32 /dev/nvme0n1p1
mkswap /dev/nvme0n1p2
swapon /dev/nvme0n1p2
mkfs.ext4 -F /dev/nvme0n1p3
echo "[OK] Formatted"
# Mount
echo "=== Mounting ==="
mount /dev/nvme0n1p3 /mnt
mkdir -p /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot
echo "[OK] Mounted"
# Add T2 repo
echo "=== Adding T2 repo ==="
echo -e '[arch-mact2]\nServer = https://mirror.funami.tech/arch-mact2/os/x86_64\nSigLevel = Never' >> /etc/pacman.conf
pacman -Sy
echo "[OK] T2 repo added"
# Install base system
echo "=== Installing packages (this takes a while) ==="
pacstrap /mnt base base-devel linux-t2 linux-t2-headers linux-firmware apple-bcm-firmware apple-t2-audio-config t2fanrd intel-ucode iwd grub efibootmgr git sudo vim openssh networkmanager
echo "[OK] Packages installed"
# Generate fstab
echo "=== Generating fstab ==="
genfstab -U /mnt >> /mnt/etc/fstab
echo "[OK] fstab generated"
# Copy T2 repo to installed system
echo -e '[arch-mact2]\nServer = https://mirror.funami.tech/arch-mact2/os/x86_64\nSigLevel = Never' >> /mnt/etc/pacman.conf
# Create chroot setup script
cat > /mnt/root/setup.sh << 'CHROOT_EOF'
#!/bin/bash
set -e
echo "=== Configuring system ==="
# Timezone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
hwclock --systohc
echo "[OK] Timezone"
# Locale
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "[OK] Locale"
# Hostname
echo "t2server" > /etc/hostname
echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.1.1 t2server.localdomain t2server" >> /etc/hosts
echo "[OK] Hostname"
# Root password
echo ""
echo "=== Set root password ==="
passwd
# Create user
useradd -m -G wheel -s /bin/zsh sterling
echo ""
echo "=== Set password for sterling ==="
passwd sterling
echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/wheel
echo "[OK] User created"
# T2 modules
echo "apple-bce" > /etc/modules-load.d/t2.conf
sed -i 's/MODULES=()/MODULES=(apple-bce)/' /etc/mkinitcpio.conf
mkinitcpio -P
echo "[OK] T2 modules"
# GRUB
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt pcie_ports=compat"/' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
echo "[OK] GRUB"
# Services
systemctl enable NetworkManager iwd t2fanrd sshd
echo "[OK] Services enabled"
echo ""
echo "========================================="
echo " ALL DONE! Exit and reboot:"
echo " exit && umount -R /mnt && reboot"
echo " Remove USB as it reboots!"
echo "========================================="
CHROOT_EOF
chmod +x /mnt/root/setup.sh
echo ""
echo "========================================="
echo " Phase 1 complete!"
echo " Now run:"
echo " arch-chroot /mnt bash /root/setup.sh"
echo "========================================="
#!/bin/bash
set -e
echo "=== T2 Arch Server - Full Install Script ==="
echo "This will WIPE /dev/nvme0n1 completely!"
echo ""
read -p "Press Enter to continue or Ctrl+C to abort..."
# Unmount anything leftover
umount -R /mnt 2>/dev/null || true
swapoff -a 2>/dev/null || true
# Partition: 1G EFI, 8G swap, rest ext4
echo "=== Partitioning ==="
sgdisk -Z /dev/nvme0n1
sgdisk -n 1:0:+1G -t 1:ef00 /dev/nvme0n1
sgdisk -n 2:0:+8G -t 2:8200 /dev/nvme0n1
sgdisk -n 3:0:0 -t 3:8300 /dev/nvme0n1
echo "[OK] Partitioned"
# Format
echo "=== Formatting ==="
mkfs.fat -F32 /dev/nvme0n1p1
mkswap /dev/nvme0n1p2
swapon /dev/nvme0n1p2
mkfs.ext4 -F /dev/nvme0n1p3
echo "[OK] Formatted"
# Mount
echo "=== Mounting ==="
mount /dev/nvme0n1p3 /mnt
mkdir -p /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot
echo "[OK] Mounted"
# Add T2 repo
echo "=== Adding T2 repo ==="
echo -e '[arch-mact2]\nServer = https://mirror.funami.tech/arch-mact2/os/x86_64\nSigLevel = Never' >> /etc/pacman.conf
pacman -Sy
echo "[OK] T2 repo added"
# Install base system
echo "=== Installing packages (this takes a while) ==="
pacstrap /mnt base base-devel linux-t2 linux-t2-headers linux-firmware apple-bcm-firmware apple-t2-audio-config t2fanrd intel-ucode iwd grub efibootmgr git sudo vim openssh networkmanager
echo "[OK] Packages installed"
# Generate fstab
echo "=== Generating fstab ==="
genfstab -U /mnt >> /mnt/etc/fstab
echo "[OK] fstab generated"
# Copy T2 repo to installed system
echo -e '[arch-mact2]\nServer = https://mirror.funami.tech/arch-mact2/os/x86_64\nSigLevel = Never' >> /mnt/etc/pacman.conf
# Create chroot setup script
cat > /mnt/root/setup.sh << 'CHROOT_EOF'
#!/bin/bash
set -e
echo "=== Configuring system ==="
# Timezone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
hwclock --systohc
echo "[OK] Timezone"
# Locale
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "[OK] Locale"
# Hostname
echo "t2server" > /etc/hostname
echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.1.1 t2server.localdomain t2server" >> /etc/hosts
echo "[OK] Hostname"
# Root password
echo ""
echo "=== Set root password ==="
passwd
# Create user
useradd -m -G wheel -s /bin/zsh sterling
echo ""
echo "=== Set password for sterling ==="
passwd sterling
echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/wheel
echo "[OK] User created"
# T2 modules
echo "apple-bce" > /etc/modules-load.d/t2.conf
sed -i 's/MODULES=()/MODULES=(apple-bce)/' /etc/mkinitcpio.conf
mkinitcpio -P
echo "[OK] T2 modules"
# GRUB
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt pcie_ports=compat"/' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
echo "[OK] GRUB"
# Services
systemctl enable NetworkManager iwd t2fanrd sshd
echo "[OK] Services enabled"
echo ""
echo "========================================="
echo " ALL DONE! Exit and reboot:"
echo " exit && umount -R /mnt && reboot"
echo " Remove USB as it reboots!"
echo "========================================="
CHROOT_EOF
chmod +x /mnt/root/setup.sh
echo ""
echo "========================================="
echo " Phase 1 complete!"
echo " Now run:"
echo " arch-chroot /mnt bash /root/setup.sh"
echo "========================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment