lvm and luks bugs fix

This commit is contained in:
mfgbhatti 2022-01-29 22:56:22 +00:00
parent 3ceb5fa536
commit aeb377418c
2 changed files with 58 additions and 42 deletions

View File

@ -4,10 +4,10 @@
CONFIG_FILE=$(pwd)/setup.conf CONFIG_FILE=$(pwd)/setup.conf
if [[ -f "$CONFIG_FILE" ]]; then if [[ -f "$CONFIG_FILE" ]]; then
source "$CONFIG_FILE" 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 # Common functions and varibales
@ -41,15 +41,40 @@ do_btrfs() {
do_lvm() { do_lvm() {
while [[ "$i" -le "$LVM_PART_NUM" ]]; do while [[ "$i" -le "$LVM_PART_NUM" ]]; do
if [[ "$i" -eq "$LVM_PART_NUM" ]]; then if [[ "$i" -eq "$LVM_PART_NUM" ]]; then
lvcreate -l 100%FREE "$LVM_VG" -n "${LVM_NAMES[$i]}" lvcreate -l 100%FREE "$LVM_VG" -n "${LVM_NAMES[$i]}"
else else
lvcreate -L "${LVM_SIZES[$i]}" "$LVM_VG" -n "${LVM_NAMES[$i]}" lvcreate -L "${LVM_SIZES[$i]}" "$LVM_VG" -n "${LVM_NAMES[$i]}"
fi fi
i=$((i + 1)) i=$((i + 1))
done done
} }
do_partition() {
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:"$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
}
do_format() {
if [[ $FS =~ "btrfs" ]]; then
do_btrfs "$ROOT" "$PART3"
else
mkfs."$FS" "$PART3" \
"$([[ $FS == xfs || $FS == reiserfs ]] && echo "-f")" \
"$([[ $FS == vfat ]] && echo "-F32")" \
"$([[ $TRIM -eq 1 && $FS == ext4 ]] && echo "-E discard")"
fi
}
# format a partition from given list of filesystems
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
@ -62,38 +87,32 @@ reflector --age 48 --country "$ISO" -f 5 --latest 20 --protocol https --sort rat
mkdir /mnt &>/dev/null # Hiding error message if any mkdir /mnt &>/dev/null # Hiding error message if any
title "Partitioning disk" title "Partitioning disk"
# disk prep if [[ "$SDD" -eq 1 ]]; then
PART2=${DISK}p2
PART3=${DISK}p3
else
PART2=${DISK}2
PART3=${DISK}3
fi
if [[ "$LAYOUT" -eq 1 ]]; then if [[ "$LAYOUT" -eq 1 ]]; then
sgdisk -Z "$DISK" # zap all on disk do_partition
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:"$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" -eq 1 ]]; then
PART2=${DISK}p2
PART3=${DISK}p3
else
PART2=${DISK}2
PART3=${DISK}3
fi
elif [[ "$LAYOUT" -eq 1 && "$DEFAULT" -eq 1 ]]; then
make_boot "$BOOT" "$PART2" make_boot "$BOOT" "$PART2"
do_btrfs "$ROOT" "$PART3" do_format
elif [[ "$LAYOUT" -eq 1 && "$LVM" -eq 1 ]]; then elif [[ "$LVM" -eq 1 ]]; then
do_partition
do_format
pvcreate "$PART3" pvcreate "$PART3"
vgcreate "$LVM_VG" "$PART3" vgcreate "$LVM_VG" "$PART3"
do_lvm do_lvm
elif [[ "$LAYOUT" -eq 1 && "$LUKS" -eq 1 && "$LVM" -eq 1 ]]; then elif [[ "$LUKS" -eq 1 ]]; then
do_partition
do_format
# enter luks password to cryptsetup and format root partition # enter luks password to cryptsetup and format root partition
echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART3" - echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART3" -
# open luks container and ROOT will be place holder # open luks container and ROOT will be place holder
echo -n "$LUKS_PASSWORD" | cryptsetup open "$PART3" "$ROOT" - echo -n "$LUKS_PASSWORD" | cryptsetup open "$PART3" "$ROOT" -
pvcreate "$LUKS_PATH" pvcreate "$LUKS_PATH"
vgcreate "$LVM_VG" "$LUKS_PATH" vgcreate "$LVM_VG" "$LUKS_PATH"
@ -125,9 +144,9 @@ title "Arch Install on Main Drive"
# for test purposes # for test purposes
pacstrap "$MOUNTPOINT" base linux linux-firmware vim --needed --noconfirm 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 #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
cp -R "${SCRIPT_DIR}" /mnt/root/ArchTitus cp -R "${SCRIPT_DIR}" /mnt/root/ArchTitus
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
@ -185,9 +204,9 @@ title "Checking for low memory systems <8G "
# TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') # TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
TOTALMEM=$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*') TOTALMEM=$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*')
if [[ $TOTALMEM -lt 8000000 ]]; then if [[ $TOTALMEM -lt 8000000 ]]; then
# Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. # Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything.
mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly. mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly.
chattr +C /mnt/opt/swap # apply NOCOW, btrfs needs that. chattr +C /mnt/opt/swap # apply NOCOW, btrfs needs that.
dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress
chmod 600 /mnt/opt/swap/swapfile # set permissions. chmod 600 /mnt/opt/swap/swapfile # set permissions.
@ -195,7 +214,7 @@ if [[ $TOTALMEM -lt 8000000 ]]; then
mkswap /mnt/opt/swap/swapfile mkswap /mnt/opt/swap/swapfile
swapon /mnt/opt/swap/swapfile swapon /mnt/opt/swap/swapfile
# The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself. # The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself.
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. echo "/opt/swap/swapfile none swap sw 0 0" >>/mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
fi fi
title "SYSTEM READY FOR 1-setup.sh" title "SYSTEM READY FOR 1-setup.sh"

View File

@ -247,19 +247,16 @@ set_partion_layout() {
case "$REPLY" in case "$REPLY" in
1) 1)
set_option "LAYOUT" 1 set_option "LAYOUT" 1
set_option "DEFAULT" 1
break break
;; ;;
2) 2)
set_lvm set_lvm
set_option "LAYOUT" 1
set_option "LVM" 1 set_option "LVM" 1
set_option "LUKS" 0 set_option "LUKS" 0
break break
;; ;;
3) 3)
set_lvm set_lvm
set_option "LAYOUT" 1
set_option "LUKS" 1 set_option "LUKS" 1
set_option "LVM" 1 set_option "LVM" 1
set_option "LUKS_PATH" "/dev/mapper/ROOT" set_option "LUKS_PATH" "/dev/mapper/ROOT"