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
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC1091,SC2001
|
# shellcheck disable=SC1091,SC2001
|
||||||
|
# shellcheck source=./setup.conf
|
||||||
|
|
||||||
|
CONFIG_FILE=$(pwd)/setup.conf
|
||||||
if [[ -f $(pwd)/setup.conf ]]; then
|
if [[ -f "$CONFIG_FILE" ]]; then
|
||||||
source setup.conf
|
source "$CONFIG_FILE"
|
||||||
else
|
else
|
||||||
echo "missing file: setup.conf"
|
echo "Missing file: setup.conf"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
logo
|
||||||
title "Setting up mirrors for faster downloads"
|
title "Setting up mirrors for faster downloads"
|
||||||
install_pkg pacman-contrib reflector rsync gptfdisk btrfs-progs
|
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"
|
title "Partitioning disk"
|
||||||
# disk prep
|
# disk prep
|
||||||
sgdisk -Z "$DISK" # zap all on disk
|
if [[ "$LAYOUT" -eq 1 ]]; then
|
||||||
sgdisk -a 2048 -o "$DISK" # new gpt disk 2048 alignment
|
sgdisk -Z "$DISK" # zap all on disk
|
||||||
if [[ "$LAYOUT" ]]; then
|
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 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 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
|
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
|
|
||||||
|
if [[ "$UEFI" -eq 0 ]]; then
|
||||||
sgdisk -A 1:set:2 "$DISK"
|
sgdisk -A 1:set:2 "$DISK"
|
||||||
fi
|
fi
|
||||||
if [[ "$SDD" ]]; then
|
|
||||||
|
if [[ "$SDD" -eq 1 ]]; then
|
||||||
PART2=${DISK}p2
|
PART2=${DISK}p2
|
||||||
PART3=${DISK}p3
|
PART3=${DISK}p3
|
||||||
else
|
else
|
||||||
PART2=${DISK}2
|
PART2=${DISK}2
|
||||||
PART3=${DISK}3
|
PART3=${DISK}3
|
||||||
fi
|
fi
|
||||||
title "Creating Filesystems"
|
elif [[ "$LAYOUT" -eq 1 && "$DEFAULT" -eq 1 ]]; then
|
||||||
mkfs.vfat -F32 -n "EFIBOOT" "$PART2"
|
make_boot "$BOOT" "$PART2"
|
||||||
mkfs.btrfs -L "ROOT" "$PART3" -f
|
do_btrfs "$ROOT" "$PART3"
|
||||||
mount -t btrfs "$PART3" /mnt
|
|
||||||
|
|
||||||
for x in "${SUBVOLUMES[@]}"; do
|
|
||||||
btrfs subvolume create /mnt/"${x}"
|
|
||||||
done
|
|
||||||
|
|
||||||
umount /mnt
|
elif [[ "$LAYOUT" -eq 1 && "$LVM" -eq 1 ]]; then
|
||||||
mount -o "$MOUNTOPTION",subvol=@ "$PART3" /mnt
|
pvcreate "$PART3"
|
||||||
|
vgcreate "$LVM_VG" "$PART3"
|
||||||
|
do_lvm
|
||||||
|
|
||||||
for _y in "${SUBVOLUMES[@]:1}"; do
|
elif [[ "$LAYOUT" -eq 1 && "$LUKS" -eq 1 && "$LVM" -eq 1 ]]; then
|
||||||
y="$(echo "$_y" | sed 's/@//g')"
|
# enter luks password to cryptsetup and format root partition
|
||||||
mkdir /mnt/"${y}"
|
echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART3" -
|
||||||
done
|
# 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
|
else
|
||||||
modprobe dm-mod
|
modprobe dm-mod
|
||||||
vgscan &>/dev/null
|
vgscan &>/dev/null
|
||||||
vgchange -ay &>/dev/null
|
vgchange -ay &>/dev/null
|
||||||
|
# need to address boot partition
|
||||||
|
# need to get root partition
|
||||||
|
# need to format root partition
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# mount target
|
# mount target
|
||||||
mkdir /mnt/boot
|
mkdir "$MOUNTPOINT"/boot
|
||||||
mkdir /mnt/boot/efi
|
mount -t vfat -L EFIBOOT "$MOUNTPOINT"/boot/
|
||||||
mount -t vfat -L EFIBOOT /mnt/boot/
|
|
||||||
|
|
||||||
if ! grep -qs '/mnt' /proc/mounts; then
|
if ! grep -qs '/mnt' /proc/mounts; then
|
||||||
echo "Drive is not mounted can not continue"
|
echo "Drive is not mounted can not continue"
|
||||||
|
|
@ -80,7 +122,9 @@ if ! grep -qs '/mnt' /proc/mounts; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
title "Arch Install on Main Drive"
|
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
|
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
|
||||||
|
|
||||||
genfstab -U /mnt >> /mnt/etc/fstab
|
genfstab -U /mnt >> /mnt/etc/fstab
|
||||||
|
|
@ -127,92 +171,6 @@ cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
|
||||||
# # mount partitions
|
# # mount partitions
|
||||||
# mount "$DISK"2 /mnt
|
# mount "$DISK"2 /mnt
|
||||||
# mkdir /
|
# 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 "
|
# echo -ne "
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue