Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB

  1. #!/bin/bash
  2. # Disk setup
  3. echo -n "What is the install device: "
  4. read $device
  5. echo "Installing to $device... (Enter to continue)"
  6. read $_
  7. # Disk wipe
  8. echo "[INFO]: Wiping disk"
  9. cryptsetup open --type plain -d /dev/urandom $device wipe
  10. dd if=/dev/zero of=/dev/mapper/wipe status=progress
  11. cryptsetup close wipe
  12. # Cleaning device from previous LUKS setups
  13. cryptsetup erase $device
  14. wipefs -a device
  15. # Set partition table
  16. parted $device mklabel gpt
  17. # Create the boot partition
  18. echo "[INFO]: Creating boot partition"
  19. parted -a optimal $device mkpart 1 primary 0% 512MB
  20. mkfs.fat -F32 "$device"1
  21. echo -n "Enter swap size + 512MB: "
  22. read $swap_size
  23. echo "Installing to $swap_size... (Enter to continue)"
  24. read $_
  25. # Create the swap partition
  26. echo "[INFO]: Creating swap partition"
  27. parted -a optimal $device mkpart 2 primary 512MB $swap_size
  28. echo "[INFO]: Enter password for swap encryption"
  29. cryptsetup luksFormat "$device"2
  30. sudo dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  31. sudo chmod 600 /root/.keys/swap-keyfile
  32. echo "[INFO]: Re-Enter password for swap encryption"
  33. sudo cryptsetup luksAddKey "$device"2 /root/.keys/swap-keyfile
  34. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  35. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$device"2 swap
  36. mkswap /dev/mapper/swap
  37. swapon /dev/mapper/swap
  38. # Create the root partition
  39. echo "[INFO]: Creating root partition"
  40. parted -a optimal $device mkpart 3 primary $swap_size 100%
  41. echo "[INFO]: Enter password for root encryption"
  42. cryptsetup luksFormat "$device"3
  43. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  44. sudo chmod 600 /root/.keys/root-keyfile
  45. echo "[INFO]: Re-Enter password for root encryption"
  46. sudo cryptsetup luksAddKey "$device"3 /root/.keys/root-keyfile
  47. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  48. cryptsetup open --key-file="/root/.keys/root-keyfile" "$device"3 root
  49. mkfs.ext4 /dev/mapper/root
  50. mkdir /mnt/sys
  51. mount "$device"1 /mnt/sys
  52. mkdir /mnt/sys/boot
  53. mount "$device"1 /mnt/sys/boot
  54. pacstrap /mnt/sys base linux linux-firmware base-devel git vim
  55. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  56. # Run on chrooted arch install
  57. cp -r ./chroot /mnt/sys/install
  58. cp -r /root/.keys /mnt/sys/root
  59. echo -n "$device" > /mnt/sys/install/device
  60. arch-chroot /mnt/sys /install/install.sh