Add option to not wipe home partition if used

This commit is contained in:
Phillip 2024-09-07 22:23:53 +01:00
parent 10f6b499aa
commit dc6af1b41d

View File

@ -1,17 +1,16 @@
#!/bin/bash #!/bin/bash
# Set mount options for disks
export MNTOPTIONS ="noatime,compress=zstd,ssd,commit=120"
echo "We just need to ask some questions before installing" echo "We just need to ask some questions before installing"
# Get drive values for installation # Get drive values for installation
lsblk lsblk
# Set EFI and root partitions
read -p 'Please enter the drive value for the root partition, this partition will be wiped and formatted: ' rootpar read -p 'Please enter the drive value for the root partition, this partition will be wiped and formatted: ' rootpar
read -p 'Please enter the drive value for the EFI partition: ' efipar read -p 'Please enter the drive value for the EFI partition: ' efipar
# Format the root partition to ext4 # Format the root partition to ext4
mkfs.ext4 /dev/$rootpar mkfs.ext4 /dev/$rootpar
# Mount root partition # Mount root partition
mount -o $MNTOPTIONS /dev/$rootpar /mnt mount /dev/$rootpar /mnt
# Ask if the EFI partition should be wiped before mounting # Ask if the EFI partition should be wiped before mounting
read -p "Do you wish to wipe the EFI partition? If you already have an existing OS installed, say No. " yesno read -p "Do you wish to wipe the EFI partition? If you already have an existing OS installed, type 'No': " yesno
case $yesno in case $yesno in
[yesYesYy]* ) [yesYesYy]* )
mkfs.fat -F32 /dev/$efipar mkfs.fat -F32 /dev/$efipar
@ -25,9 +24,17 @@ esac
read -p "Do you wish to set a home partition? " yesno read -p "Do you wish to set a home partition? " yesno
case $yesno in case $yesno in
[yesYesYy]* ) [yesYesYy]* )
read -p 'Please enter the drive value for the home partition, this partition will be wiped: ' homepar read -p 'Please enter the drive value for the home partition, this partition will be wiped: ' homepar
mkfs.ext4 /dev/$homepar read -p 'Do you wish to wipe the home partition? ' wipeyesno
;; case $wipeyesno in
[yesYesYy]* )
mkfs.ext4 /dev/$homepar
;;
[noNoNn]* )
echo "The home partition will not be wiped"
;;
* ) echo "Please answer yes (Yes, y, Y) or no (No, n, N)";;
esac
[noNoNn]* ) [noNoNn]* )
echo "A home partition will not be used in this installation" echo "A home partition will not be used in this installation"
;; ;;
@ -49,7 +56,7 @@ pacstrap -i /mnt base base-devel linux linux-firmware rsync networkmanager grub
mkdir /mnt/boot/efi mkdir /mnt/boot/efi
mount /dev/$efipar /mnt/boot/efi mount /dev/$efipar /mnt/boot/efi
if test -z "$homepar"; then if test -z "$homepar"; then
mount -o $MNTOPTIONS /dev/$homepar /mnt/home mount /dev/$homepar /mnt/home
fi fi
# Generate a fstab file # Generate a fstab file
genfstab -U /mnt >> /mnt/etc/fstab genfstab -U /mnt >> /mnt/etc/fstab