diff options
Diffstat (limited to 'stages/first_stage.sh')
-rw-r--r-- | stages/first_stage.sh | 66 |
1 files changed, 66 insertions, 0 deletions
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 |