From c0a0a78181b56ac68ea486b11700d766f5d98bdf Mon Sep 17 00:00:00 2001 From: proledatarian Date: Sat, 12 Feb 2022 15:29:17 +0000 Subject: [PATCH] Added script to partition drive. --- partition.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 partition.sh diff --git a/partition.sh b/partition.sh new file mode 100644 index 0000000..22b1a9a --- /dev/null +++ b/partition.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +#PS3="Please select a disk to partition:" +echo "Please select a disk to partition:" + +# Don't separate values by space. +IFS=$'\n' + +# Set variable containing name and size of all disks. +disks=( $(lsblk -d | tail -n+2 | awk '{print $1" "$4}') ) + +# Declare the array. +declare -a disks + +# Select value on array. +select disk in ${disks[*]} +do +IFS=' ' +array=($disk) +dev="${array[0]}" + +echo "Partitioning /dev/$dev." +echo "Clearing existing partitioning table." +sgdisk -Z /dev/$dev && +echo -e + +size="${array[1]%?}" +echo "Creating boot partition of 256 MB." +sgdisk -n 1:0:+256M /dev/$dev && +echo -e + +echo "Creating system partition of $size GB." +sgdisk -n 2:0:0 /dev/$dev + +echo "This is your new partition table:" +lsblk +break +done