#!/bin/bash # enter the void - developed by acidvegas (https://git.acid.vegas/void) set -xev # Configuration DRIVE=/dev/sdb # can be /dev/sda, /dev/nvme0n1, etc HOSTNAME=blackhole SWAP_SIZE=4 # In GB (set to 0 to disable) TIMEZONE=America/New_York USERNAME=acidvegas WIFI_SSID= # Leave blank if you don't want to use wifi WIFI_PASS= WIFI_DEV=wlp3s0 # Helper function to handle drive partitions get_partition() { local drive=$1 local part_num=$2 if [[ $drive == *"nvme"* ]]; then echo "${drive}p${part_num}" else echo "${drive}${part_num}" fi } setup_network() { if [ ! -z "$WIFI_SSID" ]; then if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then printf "Wifi is blocked, attempting to unblock... (make sure to handle this after reboot)\n" rfkill unblock wifi fi wpa_passphrase "$WIFI_SSID" "$WIFI_PASS" | wpa_supplicant -i $WIFI_DEV -c /dev/stdin fi } setup_partition() { xbps-install -u xbps xbps-install -Su xbps-install parted PART1=$(get_partition $DRIVE 1) PART2=$(get_partition $DRIVE 2) wipefs -a $DRIVE parted $DRIVE --script mklabel gpt parted $DRIVE --script mkpart primary fat32 1MiB 513MiB parted $DRIVE --script set 1 esp on parted $DRIVE --script mkpart primary ext4 513MiB 100% partprobe $DRIVE mkfs.vfat $PART1 mkfs.ext4 $PART2 mount $PART2 /mnt mkdir -p /mnt/boot/efi mount $PART1 /mnt/boot/efi } setup_install() { REPO=https://repo-default.voidlinux.org/current mkdir -p /mnt/var/db/xbps/keys cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/ xbps-install -S -r /mnt -R "$REPO" base-system linux printf "entering chroot...remember to run setup_chroot() inside the chroot!\n" xchroot /mnt /bin/bash } setup_chroot() { passwd xbps-install -u xbps xbps-install -Su xbps-install void-repo-nonfree xbps-install -Su xbps-install intel-ucode ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/ useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime hwclock --systohc printf "$HOSTNAME\n" > /etc/hostname printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\nCGROUP_MODE=\"unified\"\n" > /etc/rc.conf printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales printf "LANG=en_US.UTF-8\n" > /etc/locale.conf xbps-reconfigure -f glibc-locales PART1=$(get_partition $DRIVE 1) PART2=$(get_partition $DRIVE 2) printf "UUID=$(blkid -s UUID -o value $PART2) / ext4 defaults,noatime 0 1\n" > /etc/fstab printf "UUID=$(blkid -s UUID -o value $PART1) /boot/efi vfat defaults,noatime 0 1\n" >> /etc/fstab printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab if [ $SWAP_SIZE -gt 0 ]; then touch /swapfile dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress chmod 0600 /swapfile mkswap /swapfile swapon /swapfile printf "/swapfile none swap sw 0 0\n" >> /etc/fstab fi xbps-install grub-x86_64-efi grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --recheck xbps-reconfigure -fa linux grub-mkconfig -o /boot/grub/grub.cfg exit } if [ "$#" -ne 1 ]; then printf "usage: $0 [network|partition|install|chroot|final]\n" exit 1 fi case "$1" in network) setup_network ;; partition) setup_partition ;; install) setup_install ;; chroot) setup_chroot ;; final) umount -R /mnt; reboot ;; *) printf "usage: $0 [network|partition|install|chroot|final]\n"; exit 1 ;; esac