Skip to content

Instantly share code, notes, and snippets.

@polkaulfield
Created February 24, 2021 08:42
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 polkaulfield/afd0870b36413363fbc1c1b2c40f9770 to your computer and use it in GitHub Desktop.
Save polkaulfield/afd0870b36413363fbc1c1b2c40f9770 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Config
KEYMAP=es
LANG=en_US.UTF-8
REGION=Europe/Madrid
HOSTNAME=ryzen
USER=absurd
DISK=$1
KERNEL=linux-zen
BASE_PKGS="base base-devel linux-firmware"
GPU_DRIVERS=xf86-video-amdgpu
PACKAGES="vim git networkmanager gdm gnome-shell gnome-control-center gnome-tweaks gnome-terminal nautilus file-roller gedit eog lollypop gnome-backgrounds gnome-disk-utility gnome-keyring totem gnome-calculator gnome-system-monitor xdg-user-dirs-gtk chromium"
SERVICES="NetworkManager.service gdm.service"
CPU_MICROCODE=amd-ucode
FS_TYPE=ext4
# Check arguments
if [ -f $DISK ]; then
echo Usage: $0 DISK
exit
fi
# Checking if disk is nvme and set partition names
if [[ "$DISK" == "/dev/nvme"*"n"* ]]; then
DISK="$DISK"p
fi
BOOT_PART="$DISK"1
ROOT_PART="$DISK"2
# Creating GPT partition table and boot and root partitions on $DISK ...
parted $DISK mklabel gpt mkpart primary fat32 1MiB 512MiB set 1 esp on mkpart root $FS_TYPE 512MiB 100%
mkfs.ext4 $ROOT_PART
mount $ROOT_PART /mnt
# Formatting $BOOT_PART as boot partition...
mkfs.fat -F32 $BOOT_PART
mkdir /mnt/boot
mount $BOOT_PART /mnt/boot
# Running pacstrap with $BASE_PKGS ...
eval pacstrap /mnt $BASE_PKGS $KERNEL $CPU_MICROCODE $GPU_DRIVERS
# Creating fstab...
genfstab -U /mnt >> /mnt/etc/fstab
# Chrooting...
cat << EOF | arch-chroot /mnt
ln -sf /usr/share/zoneinfo/$REGION /etc/localtime
hwclock --systohc
sed -i s/\#$LANG\ UTF-8/$LANG\ UTF-8/g /etc/locale.gen
locale-gen
echo LANG=$LANG > /etc/locale.conf
echo KEYMAP=$KEYMAP > /etc/vconsole.conf
echo $HOSTNAME > /etc/hostname
echo 127.0.0.1 localhost > /etc/hosts
echo ::1 localhost >> /etc/hosts
echo 127.0.1.1 $HOSTNAME.localdomain $HOSTNAME >> /etc/hosts
bootctl --path=/boot install
echo title Arch Linux > /boot/loader/entries/arch.conf
echo linux /vmlinuz-$KERNEL >> /boot/loader/entries/arch.conf
echo initrd /$CPU_MICROCODE.img >> /boot/loader/entries/arch.conf
echo initrd /initramfs-$KERNEL.img >> /boot/loader/entries/arch.conf
echo options root="UUID=$(blkid | grep $ROOT_PART | cut -d '"' -f 2)" rw >> /boot/loader/entries/arch.conf
echo default arch > /boot/loader/loader.conf
echo timeout 0 >> /boot/loader/loader.conf
echo console-mode 0 >> /boot/loader/loader.conf
echo editor no >> /boot/loader/loader.conf
pacman -S --noconfirm $PACKAGES
echo '# set scheduler for NVMe' > /etc/udev/rules.d/60-ioschedulers.rules
echo 'ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"' >> /etc/udev/rules.d/60-ioschedulers.rules
echo '# set scheduler for SSD and eMMC' >> /etc/udev/rules.d/60-ioschedulers.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"' >> /etc/udev/rules.d/60-ioschedulers.rules
echo '# set scheduler for rotating disks' >> /etc/udev/rules.d/60-ioschedulers.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"' >> /etc/udev/rules.d/60-ioschedulers.rules
systemctl enable $SERVICES
useradd -mG wheel $USER
EOF
echo "Change your password and edit visudo!"
arch-chroot /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment