From 3d4061b6cec978642f2ca9b2de9c6dd9dff5c37b Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 17 Mar 2020 13:33:26 +0100 Subject: Implement Partitioning --- stages/first_stage.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'stages/first_stage.sh') diff --git a/stages/first_stage.sh b/stages/first_stage.sh index fe5e1bb..8b91c9e 100644 --- a/stages/first_stage.sh +++ b/stages/first_stage.sh @@ -24,3 +24,69 @@ set -e echo "Entering first_stage.sh - OK" + + +# Check bootmode + +if [ -d "/sys/firmware/efi/efivars" ]; then + export boot_mode="uefi" + echo "Booted with UEFI" +else + export boot_mode="bios" + echo "Booted with legacy boot / BIOS" +fi + + +# Partition the disk + +if [ "$boot_mode" == "unknown" ]; then + echo "boot_mode unknown! - FAILED" + exit 1 +fi + +if [ "$path_to_disk" == "/dev/null" ]; then + echo "path_to_disk has still default value! - FAILED" + exit 1 +fi + +if [ "$boot_mode" == "uefi" ]; then + echo "Partitioning for UEFI mode." + wipefs -a $path_to_disk # make sure that fdisk does not ask for removing + # signatures which breaks the script + fdisk $path_to_disk << EOF +g +n +1 + ++512M +n +2 + ++200M +n +3 + + +p +w +EOF + + echo "Partitioned disk for UEFI/GPT- OK" +elif [ "$boot_mode" == "bios" ]; then + echo "Partitioning for BIOS mode." + wipefs -a $path_to_disk # make sure that fdisk does not ask for removing + # signatures which breaks the script + fdisk $path_to_disk << EOF +o +n +p +1 + + +p +w +EOF + + echo "Partitioned disk for BIOS/MBR - OK" +else +fi -- cgit v1.2.3-70-g09d2