Browse Source

Upload files to ''

master
Jean 3 years ago
parent
commit
41a1d7c35f
1 changed files with 65 additions and 0 deletions
  1. +65
    -0
      elementaryOS-Hera-Multi-partition.sh

+ 65
- 0
elementaryOS-Hera-Multi-partition.sh View File

@@ -0,0 +1,65 @@
#!/bin/bash


DISK="vd" # Change this to match your disk type (i.e. sd)
RAM="6" # Change this to match the amount of RAM on your computer (in GiB)

if [[ ! $(whoami) = "root" ]]; then # Check to see if user is not root
sudo -i # Become root through sudo
else
if [[ ${1} = "step1" ]]; then # Run before using ubuquity
parted /dev/${DISK}a mklabel gpt # Make gpt label on disk a
parted /dev/${DISK}b mklabel gpt # Make gpt label on disk b
parted /dev/${DISK}a mkpart primary fat32 0% 512MiB # Make 512MiB partition for EFI
parted /dev/${DISK}a mkpart primary ext4 512MiB 1.5GiB # Make a 1GiB partition for the bootloader (GRUB)
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
parted /dev/${DISK}b mkpart primary btrfs 0% 100% # Make a full capacity partition for the first logical volume

sleep 3 # Give the system a few seconds of rest to be on the safe side

pvcreate /dev/${DISK}a3 # Make a physical volume on disk a, partition 3
pvcreate /dev/${DISK}b1 # Make a physical volume on disk b, partition 1
vgcreate elementary-vg /dev/${DISK}a3 /dev/${DISK}b1 # Make the virst volume group
lvcreate -l 100%FREE elementary-vg -n luks # Make the virst logical volume

sleep 3 # Give the system a few seconds of rest to be on the safe side

cryptsetup luksFormat --type luks2 /dev/elementary-vg/luks # Make an encrypted volume on the virst logical volume
cryptsetup open /dev/elementary-vg/luks elementaryOS # Open the encrypted luks volume

sleep 3 # Give the system a few seconds of rest to be on the safe side

pvcreate /dev/mapper/elementaryOS # Make a physical volume inside the encrypted volume
vgcreate elementary-filesystem-vg /dev/mapper/elementaryOS # Make the second volume group
lvcreate -L ${RAM}G elementary-filesystem-vg -n swap # Make a logical volume for swap
lvcreate -l 100%FREE elementary-filesystem-vg -n root # Make a logical volume for the root filesystem

sleep 3 # Give the system a few seconds of rest to be on the safe side

parted /dev/${DISK}a set 1 esp on # Set disk a, partition 1 as the EFI partition

mkfs.fat -F32 /dev/${DISK}a1 # Format disk a, partition 1 as fat32
mkfs.ext4 /dev/${DISK}a2 # Format disk a, partition 2 as extended 4
mkswap /dev/elementary-filesystem-vg/swap # Format the swap volume
mkfs.btrfs /dev/elementary-filesystem-vg/root # Format the root filesystem as btrfs
elif [[ ${1} = "step2" ]]; then # Mounts things and other stuff
vgscan && sleep 1
vgchange -ay && sleep 1
lvscan && sleep 1
mount /dev/elementary-filesystem-vg/root /mnt/ && sleep 1
mount /dev/${DISK}a2 /mnt/@/boot/ && sleep 1
mount -o bind /dev/ /mnt/@/dev/ && sleep 1
mount -o bind /proc/ /mnt/@/proc/ && sleep 1
mount -o bind /sys/ /mnt/@/sys/ && sleep 1
cp ${0} /mnt/@/ && sleep 1
chroot /mnt/@/
elif [[ ${1} = "step3" ]]; then
cryptsetup luksDump /dev/elementary-vg/luks | grep UUID # Display the UUID of the encrypted volume to be copied
read -p "Please copy the UUID above, then pres [ENTER] to continue..."
echo 'elementaryOS UUID=<uuid> none luks' > /etc/crypttab && sleep 1 # Creates and mostly populates the crypttab file
nano /etc/crypttab && sleep 1 # Opens the crypttab file in nano so the encrypted volume's UUID can be entered
update-initramfs -u -k all # Update the initramfs
else
echo 'Please enter either step1 (pre-ubiquity), step2 (post ubiquity), or step3 (after chrooting)' # Displays if no options were stated when running the script
fi
fi