[TASK] Allow different hdds for installation

This commit is contained in:
Sebastian Fischer 2026-02-13 21:25:37 +01:00
parent 88929f83e6
commit cdb63d1114

View File

@ -4,40 +4,51 @@ sudo -i
loadkeys de
lsbkl
lsblk
# Disk selection
DEFAULT_DISK="/dev/sda"
read -p "Disk to install to [${DEFAULT_DISK}]: " DISK
DISK="${DISK:-$DEFAULT_DISK}"
if [ ! -b "$DISK" ]; then
echo "Error: ${DISK} is not a valid block device."
exit 1
fi
echo "Using disk: ${DISK}"
# Partitioning
read -p "Create partitions table? DELETES ALL DATA! (j/N): " answer
if [ "$answer" = "j" ] || [ "$answer" = "J" ]; then
# GPT-partition table
parted /dev/sda -- mklabel gpt
parted "${DISK}" -- mklabel gpt
# EFI-partition (512 MB)
parted /dev/sda -- mkpart esp fat32 1MB 512MB
parted /dev/sda -- set 1 esp on
parted "${DISK}" -- mkpart esp fat32 1MB 512MB
parted "${DISK}" -- set 1 esp on
# Swap-partition (8 GB)
parted /dev/sda -- mkpart swap linux-swap 512MB 8626MB
parted "${DISK}" -- mkpart swap linux-swap 512MB 8626MB
# Root-partition (ca. 45 GB)
parted /dev/sda -- mkpart root ext4 8636MB 40000MB
parted "${DISK}" -- mkpart root ext4 8636MB 40000MB
# Home-partition (Rest)
parted /dev/sda -- mkpart home ext4 40000MB 100%
parted "${DISK}" -- mkpart home ext4 40000MB 100%
fi
# Check results
parted /dev/sda -- print
parted "${DISK}" -- print
mkfs.fat -F 32 -n boot /dev/sda1
mkswap -L swap /dev/sda2
mkfs.ext4 -L nixos /dev/sda3
mkfs.fat -F 32 -n boot ${DISK}1
mkswap -L swap ${DISK}2
mkfs.ext4 -L nixos ${DISK}3
read -p "Format Home-partition? Deletes all userdata! (j/N): " answer
if [ "$answer" = "j" ] || [ "$answer" = "J" ]; then
# Format home-partition
mkfs.ext4 -L home /dev/sda4
mkfs.ext4 -L home ${DISK}4
fi