Skip to content

Instantly share code, notes, and snippets.

@hamidzr
Last active December 15, 2019 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamidzr/a2003f58bd075dd3a79212cf9a558501 to your computer and use it in GitHub Desktop.
Save hamidzr/a2003f58bd075dd3a79212cf9a558501 to your computer and use it in GitHub Desktop.
basic arch setup script. download it with `wget tinyurl.com/simplearchsetup`
#!/bin/bash
# description: basic arch setup script, pass in the a part eg: ./archSetup.sh p1
# assumptions:
# UEFI + GPT
# partitions: esp root swap (no lvm)
# alert: dont format esp partition if dual booting the system
# argument: #1: p1 or p2
# init
ESPDEVICE=/dev/nvme0n1p1
SWAPDEVICE=/dev/nvme0n1p7
ROOTDEVICE=/dev/nvme0n1p3
HOSTNAME=hps
WORKINGMIRROR=https://arch.mirror.square-r00t.net # grab this from an existing working /etc/pacman.d/mirrorlist
FULL_MIRROR_STR="Server = $WORKINGMIRROR/archlinux/\$repo/os/\$arch"
function pause(){
echo "$* (enter to continue)"
sleep 1
read
}
lsblk
echo ESPDEVICE: $ESPDEVICE
echo SWAPDEVICE: $SWAPDEVICE
echo ROOTDEVICE: $ROOTDEVICE
pause "did you fill in all the configuartions?"
if [ $1 == p1 ]; then
# cleanup
umount -R /mnt
pause "did you gdisk/parted partiotions ? formatting $ESPDEVICE $ROOTDEVICE $SWAPDEVICE"
mkfs.ext4 $ROOTDEVICE
mkswap $SWAPDEVICE
mkfs.fat -F32 $ESPDEVICE
mount $ROOTDEVICE /mnt
mkdir /mnt/boot
mount $ESPDEVICE /mnt/boot
swapon $SWAPDEVICE
pause 'You should have partitioned and mounted everything by this point (esp swap root .. ) gdisk parted'
echo $FULL_MIRROR_STR > /etc/pacman.d/mirrorlist
curl -o /etc/pacman.d/mirrorlist https://www.archlinux.org/mirrorlist/all/
timedatectl set-ntp true
pacman -S wget --noconfirm
echo $FULL_MIRROR_STR > /etc/pacman.d/mirrorlist
pacman -Syy
pacstrap /mnt base base-devel
genfstab -U /mnt > /mnt/etc/fstab
arch-chroot /mnt
elif [ $1 == p2 ]; then
### moved into a new root!
echo $FULL_MIRROR_STR > /etc/pacman.d/mirrorlist
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
hwclock --systohc
echo en_US.UTF-8 UTF-8 > /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
echo $HOSTNAME > /etc/hostname
echo "127.0.0.1 $HOSTNAME.localdomain $HOSTNAME" > /etc/hosts
pacman --noconfirm -S iw wpa_supplicant dialog vim tree os-prober ranger openssh git intel-ucode mkinitcpio dhcpcd dhclient man
# mkinitcpio -p linux # not necessary..
passwd
# setup wifi
echo setting up wifi
echo "ctrl_interface=/run/wpa_supplicant
update_config=1" > /etc/wpa_supplicant/wpa_supplicant.conf
# update wlan0 name to match wireless interface
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
echo "setup bootloader now. Depending on your setup, probably UEFI + GPT . ( grub or systemd-boot"
pause "Enter to installing systemd-boot "
echo "here is your root PARTUUID"
blkid -s PARTUUID -o value $ROOTDEVICE
bootctl --path=/boot install
echo "title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$(blkid -s PARTUUID -o value $ROOTDEVICE) rw" > /boot/loader/entries/arch.conf
echo "default arch
timeout 2
editor 0" > /boot/loader/loader.conf
elif [ $1 == p3 ]; then
echo installing xorg server
pause "make sure logged in as a normal user and not root"
dhcpcd
pacman -S reflector
reflector --verbose --latest 50 --sort rate --save /etc/pacman.d/mirrorlist
pacman -S xorg-server xorg-xinit exa xorg-fonts-alias xorg-fonts-encodings xorg-fonts-misc
pacman -S awesome
echo install yay
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
echo "you can do the rest yourself.."
fi
@hamidzr
Copy link
Author

hamidzr commented May 7, 2017

tinyurl.com/simplearchsetup
install wget and connect to net using netctl or ethernet

@hamidzr
Copy link
Author

hamidzr commented Oct 4, 2017

TODO:

  • add gpt uefi example
    parted
  • add description about p1 and p2
  • can't makepkg as root!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment