Skip to content

Instantly share code, notes, and snippets.

@udf
Created July 19, 2021 18:22
Show Gist options
  • Save udf/c4b0ae3e0a9990d38177532ddfdb0f65 to your computer and use it in GitHub Desktop.
Save udf/c4b0ae3e0a9990d38177532ddfdb0f65 to your computer and use it in GitHub Desktop.
Arch Linux TAS
#!/usr/bin/env bash
### mirror setup
# mkdir /tmp/pkg
# cd /tmp/pkg
# ln -s /var/lib/pacman/sync/*.db .
# ln -s /var/cache/pacman/pkg/* .
# python -m http.server 8080
ISOFILE=archlinux-2021.07.01-x86_64.iso
mkdir -p /tmp/arch
cd /tmp/arch
cp -n ~/Downloads/$ISOFILE .
rm -f arch.img
qemu-img create -f qcow2 arch.img 4G
{
cat <<EOF
set timeout -1
spawn qemu-system-x86_64 -enable-kvm -boot d -drive file=arch.img -m 2G -cdrom $ISOFILE -cpu host -smp 8 -serial stdio -boot order=c
# Edit boot options and enable serial console
expect "Arch Linux install"
send "\t console=ttyS0\n"
expect "login:"
send "root\n"
# Partition and format the drive
# Stop reflector, set the mirror server, disable signature verification, and install the system
expect "@archiso"
send "parted /dev/sda mklabel msdos mkpart primary 0% 100%; mkfs.ext4 /dev/sda1; mount /dev/sda1 /mnt; systemctl stop reflector; echo 'Server = http://10.0.2.2:8080' > /etc/pacman.d/mirrorlist; sed -i 's/Required DatabaseOptional/Never/' /etc/pacman.conf; pacstrap /mnt base linux grub; arch-chroot /mnt; reboot\n"
# Disable grub timeout and install grub
expect "]# "
send "sed -i 's/OUT=5/OUT=0/' /etc/default/grub; grub-install /dev/sda; grub-mkconfig -o /boot/grub/grub.cfg; exit\n"
expect eof
EOF
} | expect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment