added lvm and luks
This commit is contained in:
parent
adac336e27
commit
3ceb5fa536
196
0-preinstall.sh
196
0-preinstall.sh
|
|
@ -1,14 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC1091,SC2001
|
||||
# shellcheck source=./setup.conf
|
||||
|
||||
|
||||
if [[ -f $(pwd)/setup.conf ]]; then
|
||||
source setup.conf
|
||||
CONFIG_FILE=$(pwd)/setup.conf
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
source "$CONFIG_FILE"
|
||||
else
|
||||
echo "missing file: setup.conf"
|
||||
echo "Missing file: setup.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Common functions and varibales
|
||||
|
||||
BOOT=EFIBOOT
|
||||
ROOT=ROOT
|
||||
MOUNTPOINT="/mnt"
|
||||
|
||||
make_boot() {
|
||||
mkfs.vfat -F32 -n "$1" "$2"
|
||||
}
|
||||
|
||||
do_btrfs() {
|
||||
mkfs.btrfs -L "$1" "$2" -f
|
||||
mount -t btrfs "$2" "$MOUNTPOINT"
|
||||
|
||||
title "Creating subvolumes and directories"
|
||||
for x in "${SUBVOLUMES[@]}"; do
|
||||
btrfs subvolume create "$MOUNTPOINT"/"${x}"
|
||||
done
|
||||
|
||||
umount /mnt
|
||||
mount -o "$MOUNTOPTION",subvol=@ "$2" "$MOUNTPOINT"
|
||||
|
||||
for z in "${SUBVOLUMES[@]:1}"; do
|
||||
w="$(echo "$z" | sed 's/@//g')"
|
||||
mkdir /mnt/"${w}"
|
||||
mount -o "$MOUNTOPTION",subvol="${z}" "$2" "$MOUNTPOINT"/"${w}"
|
||||
done
|
||||
}
|
||||
|
||||
do_lvm() {
|
||||
while [[ "$i" -le "$LVM_PART_NUM" ]]; do
|
||||
if [[ "$i" -eq "$LVM_PART_NUM" ]]; then
|
||||
lvcreate -l 100%FREE "$LVM_VG" -n "${LVM_NAMES[$i]}"
|
||||
else
|
||||
lvcreate -L "${LVM_SIZES[$i]}" "$LVM_VG" -n "${LVM_NAMES[$i]}"
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
logo
|
||||
title "Setting up mirrors for faster downloads"
|
||||
install_pkg pacman-contrib reflector rsync gptfdisk btrfs-progs
|
||||
|
|
@ -22,54 +63,55 @@ mkdir /mnt &>/dev/null # Hiding error message if any
|
|||
|
||||
title "Partitioning disk"
|
||||
# disk prep
|
||||
sgdisk -Z "$DISK" # zap all on disk
|
||||
sgdisk -a 2048 -o "$DISK" # new gpt disk 2048 alignment
|
||||
if [[ "$LAYOUT" ]]; then
|
||||
if [[ "$LAYOUT" -eq 1 ]]; then
|
||||
sgdisk -Z "$DISK" # zap all on disk
|
||||
sgdisk -a 2048 -o "$DISK" # new gpt disk 2048 alignment
|
||||
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:"BIOSBOOT" "$DISK" # partition 1 (BIOS Boot Partition)
|
||||
sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:"EFIBOOT" "$DISK" # partition 2 (UEFI Boot Partition)
|
||||
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:"ROOT" "$DISK" # partition 3 (Root), default start, remaining
|
||||
if [[ ! "$UEFI" ]]; then # Checking for bios system
|
||||
sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:"$BOOT" "$DISK" # partition 2 (UEFI Boot Partition)
|
||||
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:"$ROOT" "$DISK" # partition 3 (Root), default start, remaining
|
||||
|
||||
if [[ "$UEFI" -eq 0 ]]; then
|
||||
sgdisk -A 1:set:2 "$DISK"
|
||||
fi
|
||||
if [[ "$SDD" ]]; then
|
||||
|
||||
if [[ "$SDD" -eq 1 ]]; then
|
||||
PART2=${DISK}p2
|
||||
PART3=${DISK}p3
|
||||
else
|
||||
PART2=${DISK}2
|
||||
PART3=${DISK}3
|
||||
fi
|
||||
title "Creating Filesystems"
|
||||
mkfs.vfat -F32 -n "EFIBOOT" "$PART2"
|
||||
mkfs.btrfs -L "ROOT" "$PART3" -f
|
||||
mount -t btrfs "$PART3" /mnt
|
||||
|
||||
for x in "${SUBVOLUMES[@]}"; do
|
||||
btrfs subvolume create /mnt/"${x}"
|
||||
done
|
||||
elif [[ "$LAYOUT" -eq 1 && "$DEFAULT" -eq 1 ]]; then
|
||||
make_boot "$BOOT" "$PART2"
|
||||
do_btrfs "$ROOT" "$PART3"
|
||||
|
||||
umount /mnt
|
||||
mount -o "$MOUNTOPTION",subvol=@ "$PART3" /mnt
|
||||
elif [[ "$LAYOUT" -eq 1 && "$LVM" -eq 1 ]]; then
|
||||
pvcreate "$PART3"
|
||||
vgcreate "$LVM_VG" "$PART3"
|
||||
do_lvm
|
||||
|
||||
for _y in "${SUBVOLUMES[@]:1}"; do
|
||||
y="$(echo "$_y" | sed 's/@//g')"
|
||||
mkdir /mnt/"${y}"
|
||||
done
|
||||
elif [[ "$LAYOUT" -eq 1 && "$LUKS" -eq 1 && "$LVM" -eq 1 ]]; then
|
||||
# enter luks password to cryptsetup and format root partition
|
||||
echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART3" -
|
||||
# open luks container and ROOT will be place holder
|
||||
echo -n "$LUKS_PASSWORD" | cryptsetup open "$PART3" "$ROOT" -
|
||||
pvcreate "$LUKS_PATH"
|
||||
vgcreate "$LVM_VG" "$LUKS_PATH"
|
||||
do_lvm
|
||||
|
||||
for z in "${SUBVOLUMES[@]:1}"; do
|
||||
w="$(echo "$z" | sed 's/@//g')"
|
||||
mount -o "$MOUNTOPTION",subvol="${z}" "$PART3" /mnt/"${w}"
|
||||
done
|
||||
else
|
||||
modprobe dm-mod
|
||||
vgscan &>/dev/null
|
||||
vgchange -ay &>/dev/null
|
||||
# need to address boot partition
|
||||
# need to get root partition
|
||||
# need to format root partition
|
||||
|
||||
fi
|
||||
|
||||
# mount target
|
||||
mkdir /mnt/boot
|
||||
mkdir /mnt/boot/efi
|
||||
mount -t vfat -L EFIBOOT /mnt/boot/
|
||||
mkdir "$MOUNTPOINT"/boot
|
||||
mount -t vfat -L EFIBOOT "$MOUNTPOINT"/boot/
|
||||
|
||||
if ! grep -qs '/mnt' /proc/mounts; then
|
||||
echo "Drive is not mounted can not continue"
|
||||
|
|
@ -80,7 +122,9 @@ if ! grep -qs '/mnt' /proc/mounts; then
|
|||
fi
|
||||
|
||||
title "Arch Install on Main Drive"
|
||||
pacstrap /mnt base base-devel linux linux-firmware vim nano sudo archlinux-keyring wget libnewt --noconfirm --needed
|
||||
# for test purposes
|
||||
pacstrap "$MOUNTPOINT" base linux linux-firmware vim --needed --noconfirm
|
||||
#pacstrap /mnt base base-devel linux linux-firmware vim nano sudo archlinux-keyring wget libnewt --noconfirm --needed
|
||||
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
|
||||
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
|
@ -127,92 +171,6 @@ cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
|
|||
# # mount partitions
|
||||
# mount "$DISK"2 /mnt
|
||||
# mkdir /
|
||||
# disk prep
|
||||
# sgdisk -Z ${DISK} # zap all on disk
|
||||
# sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment
|
||||
|
||||
# # create partitions
|
||||
# sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition)
|
||||
# sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition)
|
||||
# sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining
|
||||
# if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system
|
||||
# sgdisk -A 1:set:2 ${DISK}
|
||||
# fi
|
||||
# make filesystems
|
||||
|
||||
# createsubvolumes () {
|
||||
# btrfs subvolume create /mnt/@
|
||||
# btrfs subvolume create /mnt/@home
|
||||
# btrfs subvolume create /mnt/@var
|
||||
# btrfs subvolume create /mnt/@tmp
|
||||
# btrfs subvolume create /mnt/@.snapshots
|
||||
# }
|
||||
|
||||
# mountallsubvol () {
|
||||
# mount -o ${mountoptions},subvol=@home /dev/mapper/ROOT /mnt/home
|
||||
# mount -o ${mountoptions},subvol=@tmp /dev/mapper/ROOT /mnt/tmp
|
||||
# mount -o ${mountoptions},subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots
|
||||
# mount -o ${mountoptions},subvol=@var /dev/mapper/ROOT /mnt/var
|
||||
# }
|
||||
|
||||
# if [[ "${DISK}" =~ "nvme" ]]; then
|
||||
# partition2=${DISK}p2
|
||||
# partition3=${DISK}p3
|
||||
# else
|
||||
# partition2=${DISK}2
|
||||
# partition3=${DISK}3
|
||||
# fi
|
||||
|
||||
# if [[ "${FS}" == "btrfs" ]]; then
|
||||
# mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
|
||||
# mkfs.btrfs -L ROOT ${partition3} -f
|
||||
# mount -t btrfs ${partition3} /mnt
|
||||
# elif [[ "${FS}" == "ext4" ]]; then
|
||||
# mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
|
||||
# mkfs.ext4 -L ROOT ${partition3}
|
||||
# mount -t ext4 "${partition3}" /mnt
|
||||
# elif [[ "${FS}" == "luks" ]]; then
|
||||
# mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
||||
# # enter luks password to cryptsetup and format root partition
|
||||
# echo -n "${luks_password}" | cryptsetup -y -v luksFormat "${partition3}" -
|
||||
# # open luks container and ROOT will be place holder
|
||||
# echo -n "${luks_password}" | cryptsetup open "${partition3} "ROOT -
|
||||
# # now format that container
|
||||
# mkfs.btrfs -L ROOT /dev/mapper/ROOT
|
||||
# # create subvolumes for btrfs
|
||||
# mount -t btrfs /dev/mapper/ROOT /mnt
|
||||
# createsubvolumes
|
||||
# umount /mnt
|
||||
# # mount @ subvolume
|
||||
# mount -o "${mountoptions}",subvol=@ /dev/mapper/ROOT /mnt
|
||||
# # make directories home, .snapshots, var, tmp
|
||||
# mkdir -p /mnt/{home,var,tmp,.snapshots}
|
||||
# # mount subvolumes
|
||||
# mountallsubvol
|
||||
# # store uuid of encrypted partition for grub
|
||||
# echo encryped_partition_uuid="$(blkid -s UUID -o value "${partition3}")" >> setup.conf
|
||||
# fi
|
||||
|
||||
# checking if user selected btrfs
|
||||
# if [[ ${FS} =~ "btrfs" ]]; then
|
||||
# ls /mnt | xargs btrfs subvolume delete
|
||||
# btrfs subvolume create /mnt/@
|
||||
# umount /mnt
|
||||
# mount -t btrfs -o subvol=@ -L ROOT /mnt
|
||||
# fi
|
||||
|
||||
|
||||
|
||||
|
||||
# echo -ne "
|
||||
# -------------------------------------------------------------------------
|
||||
# Arch Install on Main Drive
|
||||
# -------------------------------------------------------------------------
|
||||
# "
|
||||
# pacstrap /mnt base base-devel linux linux-firmware vim nano sudo archlinux-keyring wget libnewt --noconfirm --needed
|
||||
# echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
|
||||
# # check pacstrap installed or not
|
||||
|
||||
|
||||
# echo -ne "
|
||||
# -------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue