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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

65 lines
3.7 KiB

  1. #!/bin/bash
  2. DISK="vd" # Change this to match your disk type (i.e. sd)
  3. RAM="6" # Change this to match the amount of RAM on your computer (in GiB)
  4. if [[ ! $(whoami) = "root" ]]; then # Check to see if user is not root
  5. sudo -i # Become root through sudo
  6. else
  7. if [[ ${1} = "step1" ]]; then # Run before using ubuquity
  8. parted /dev/${DISK}a mklabel gpt # Make gpt label on disk a
  9. parted /dev/${DISK}b mklabel gpt # Make gpt label on disk b
  10. parted /dev/${DISK}a mkpart primary fat32 0% 512MiB # Make 512MiB partition for EFI
  11. parted /dev/${DISK}a mkpart primary ext4 512MiB 1.5GiB # Make a 1GiB partition for the bootloader (GRUB)
  12. parted /dev/${DISK}a mkpart primary btrfs 1.5GiB 100% # Use the remaining space on disk a to make one final partition for the first logical volume
  13. parted /dev/${DISK}b mkpart primary btrfs 0% 100% # Make a full capacity partition for the first logical volume
  14. sleep 3 # Give the system a few seconds of rest to be on the safe side
  15. pvcreate /dev/${DISK}a3 # Make a physical volume on disk a, partition 3
  16. pvcreate /dev/${DISK}b1 # Make a physical volume on disk b, partition 1
  17. vgcreate elementary-vg /dev/${DISK}a3 /dev/${DISK}b1 # Make the virst volume group
  18. lvcreate -l 100%FREE elementary-vg -n luks # Make the virst logical volume
  19. sleep 3 # Give the system a few seconds of rest to be on the safe side
  20. cryptsetup luksFormat --type luks2 /dev/elementary-vg/luks # Make an encrypted volume on the virst logical volume
  21. cryptsetup open /dev/elementary-vg/luks elementaryOS # Open the encrypted luks volume
  22. sleep 3 # Give the system a few seconds of rest to be on the safe side
  23. pvcreate /dev/mapper/elementaryOS # Make a physical volume inside the encrypted volume
  24. vgcreate elementary-filesystem-vg /dev/mapper/elementaryOS # Make the second volume group
  25. lvcreate -L ${RAM}G elementary-filesystem-vg -n swap # Make a logical volume for swap
  26. lvcreate -l 100%FREE elementary-filesystem-vg -n root # Make a logical volume for the root filesystem
  27. sleep 3 # Give the system a few seconds of rest to be on the safe side
  28. parted /dev/${DISK}a set 1 esp on # Set disk a, partition 1 as the EFI partition
  29. mkfs.fat -F32 /dev/${DISK}a1 # Format disk a, partition 1 as fat32
  30. mkfs.ext4 /dev/${DISK}a2 # Format disk a, partition 2 as extended 4
  31. mkswap /dev/elementary-filesystem-vg/swap # Format the swap volume
  32. mkfs.btrfs /dev/elementary-filesystem-vg/root # Format the root filesystem as btrfs
  33. elif [[ ${1} = "step2" ]]; then # Mounts things and other stuff
  34. vgscan && sleep 1
  35. vgchange -ay && sleep 1
  36. lvscan && sleep 1
  37. mount /dev/elementary-filesystem-vg/root /mnt/ && sleep 1
  38. mount /dev/${DISK}a2 /mnt/@/boot/ && sleep 1
  39. mount -o bind /dev/ /mnt/@/dev/ && sleep 1
  40. mount -o bind /proc/ /mnt/@/proc/ && sleep 1
  41. mount -o bind /sys/ /mnt/@/sys/ && sleep 1
  42. cp ${0} /mnt/@/ && sleep 1
  43. chroot /mnt/@/
  44. elif [[ ${1} = "step3" ]]; then
  45. cryptsetup luksDump /dev/elementary-vg/luks | grep UUID # Display the UUID of the encrypted volume to be copied
  46. read -p "Please copy the UUID above, then pres [ENTER] to continue..."
  47. echo 'elementaryOS UUID=<uuid> none luks' > /etc/crypttab && sleep 1 # Creates and mostly populates the crypttab file
  48. nano /etc/crypttab && sleep 1 # Opens the crypttab file in nano so the encrypted volume's UUID can be entered
  49. update-initramfs -u -k all # Update the initramfs
  50. else
  51. echo 'Please enter either step1 (pre-ubiquity), step2 (post ubiquity), or step3 (after chrooting)' # Displays if no options were stated when running the script
  52. fi
  53. fi