Guest User

Arch-Install

a guest
Oct 21st, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.05 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This script is heavily inspired by https://gist.github.com/Th3Whit3Wolf/0150bd13f4b2667437c55b71bfb073e4
  4. # 0 - SSH
  5. # This isn't necessary but if you ssh into the computer all the other steps are copy and paste
  6. # Set a password for root
  7. #passwd
  8. # Get network access
  9. #iwctl
  10.  
  11. # """
  12. # # First, if you do not know your wireless device name, list all Wi-Fi devices:
  13. # [iwd]# device list
  14. # # Then, to scan for networks:
  15. # [iwd]# station device scan
  16. # # You can then list all available networks:
  17. # [iwd]# station device get-networks
  18. # # Finally, to connect to a network:
  19. # [iwd]# station device connect SSID
  20. # """
  21.  
  22. # Start the ssh daemon
  23. # systemctl start sshd.service
  24.  
  25. # 1 - Partitioning:
  26. #--------------cfdisk /dev/nvme0n1
  27. # nvme0n1p1 = /boot, nvme0n1p2 = SWAP, nvme0n1p3 = encrypted root
  28. # for the SWAP partition below, try and make it a bit bigger than your RAM, for hybernating
  29. # o ,
  30. # /dev/nvme0n1p1    512M          EFI System
  31. # /dev/nvme0n1p2    (the rest)    Linux Filesystem  
  32.  
  33. # 2 Encrypt Partition
  34. echo "encrypting root partition"
  35. cryptsetup luksFormat --perf-no_read_workqueue --perf-no_write_workqueue --type luks2 --cipher aes-xts-plain64 --key-size 512 --iter-time 2000 --pbkdf argon2id --hash sha3-512 /dev/nvme0n1p2
  36. cryptsetup --allow-discards --perf-no_read_workqueue --perf-no_write_workqueue --persistent open /dev/nvme0n1p2 cryptroot
  37.  
  38. # 3 - Formatting the partitions:
  39. # the first one is our ESP partition, so for now we just need to format it
  40. echo "formating EFI and cryptroot"
  41. mkfs.vfat -F32 -n "EFI" /dev/nvme0n1p1
  42. mkfs.btrfs -L Root /dev/mapper/cryptroot
  43.  
  44. # 4 - Create and Mount Subvolumes
  45. # Create subvolumes for root, home, the package cache, snapshots and the entire Btrfs file system
  46. echo "mounting cryptroot"
  47. mount /dev/mapper/cryptroot /mnt
  48. echo "creating btrfs subvolumes"
  49. btrfs sub create /mnt/@
  50. btrfs sub create /mnt/@home
  51. btrfs sub create /mnt/@paccache
  52. btrfs sub create /mnt/@var_tmp
  53. btrfs sub create /mnt/@var_log
  54. btrfs sub create /mnt/@snapshots
  55. btrfs sub create /mnt/@swap
  56. umount /mnt
  57.  
  58. # Mount the subvolumes
  59. echo "mounting all subvolumes"
  60. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@ /dev/mapper/cryptroot /mnt
  61. mkdir -p -p /mnt/{boot,home,var/cache/pacman/pkg,var/tmp,var/log,.snapshots,.swap}
  62. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@home /dev/mapper/cryptroot /mnt/home
  63. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@paccache /dev/mapper/cryptroot /mnt/var/cache/pacman/pkg
  64. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@var_tmp /dev/mapper/cryptroot /mnt/var/tmp
  65. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@var_log /dev/mapper/cryptroot /mnt/var/log
  66. mount -o noatime,nodiratime,compress=zstd,commit=60,space_cache=v2,ssd,subvol=@snapshots /dev/mapper/cryptroot /mnt/.snapshots
  67. mount -o noatime,nodiratime,compress=no,space_cache=v2,ssd,subvol=@swap /dev/mapper/cryptroot /mnt/.swap
  68.  
  69.  
  70. # Create Swapfile
  71. echo "creating swapfile"
  72. truncate -s 0 /mnt/.swap/swapfile
  73. chattr +C /mnt/.swap/swapfile
  74. btrfs property set /mnt/.swap/swapfile compression none
  75. fallocate -l 20G /mnt/.swap/swapfile
  76. chmod 600 /mnt/.swap/swapfile
  77. mkswap /mnt/.swap/swapfile
  78. swapon /mnt/.swap/swapfile
  79.  
  80. # Mount the EFI partition
  81. echo "mounting /boot"
  82. mount /dev/nvme0n1p1 /mnt/boot
  83.  
  84. # 5 Base System and /etc/fstab
  85. echo "creating new mirrorlist"
  86. reflector -c "DE" -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist
  87.  
  88.  
  89. # The following assumes you have an AMD CPU & GPU
  90. echo "running pacstrap"
  91. pacstrap /mnt base base-devel linux linux-firmware amd-ucode btrfs-progs sbsigntools \
  92.     nano zstd networkmanager mesa vulkan-radeon libva-mesa-driver mesa-vdpau \
  93.     xf86-video-amdgpu openssh refind zsh zsh-completions acpi efibootmgr\
  94.     zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting grml-zsh-config git \
  95.     pigz pbzip2 reflector plasma-meta kde-system-meta yakuake kate ark filelight kfind konsole kdf \
  96.     kdeconnect krusader ktorrent kmail dolphin-plugins gwenview kaddressbook korganizer \
  97.     krunner ksnip digikam firefox firefox-i18n-de fwupd gamemode gimp lsd man-db man-pages \
  98.     man-pages-de cantata gst-plugin-pipewire pipewire-alsa pipewire-pulse snapper \
  99.    
  100.  
  101. # generate the fstab
  102. echo "generating fstab"
  103. genfstab -U /mnt > /mnt/etc/fstab
  104.  
  105. # 6 System Configuration
  106. # Use timedatectl(1) to ensure the system clock is accurate
  107. timedatectl set-ntp true
  108. # Copy mirrorlist created earlier to new install
  109. echo "copying mirrorlist to /mnt"
  110. cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
  111. # chroot into the new system
  112. echo "chroot into new install"
  113. cp "$(dirname $(realpath $0))/Arch-install-chroot.sh" /mnt/Arch-install-chroot.sh
  114. arch-chroot /mnt
  115.  
  116.  
  117. # 12 - After instalation
  118. #systemctl enable --now NetworkManager
  119. # systemctl enable --now sshd
  120. #sudo pacman -S snapper sddm
  121. #sudo umount /.snapshots
  122. #sudo rm -r /.snapshots
  123. #sudo snapper -c root create-config /
  124. #sudo mount -a
  125. #sudo chmod 750 -R /.snapshots
  126.  
Add Comment
Please, Sign In to add comment