Create generic script for partitioning disks

This commit is contained in:
Manuel Thalmann 2023-11-24 13:59:58 +01:00
parent e4ff7b784a
commit 0476f5d9f2
3 changed files with 14 additions and 13 deletions

View file

@ -22,7 +22,8 @@ tempDir="$tempRoot/$relativeDir";
loadkeys "$ARCH_KEYMAP"; loadkeys "$ARCH_KEYMAP";
timedatectl set-timezone "$ARCH_TIMEZONE"; timedatectl set-timezone "$ARCH_TIMEZONE";
. "./partition.sh"; OS_DISK="${ARCH_DISK}" \
. "../../Common/OS/partition.sh";
pacman-key --init; pacman-key --init;
pacman-key --populate; pacman-key --populate;

View file

@ -29,4 +29,4 @@
echo "23"; echo "23";
echo "w"; echo "w";
} | fdisk "$ARCH_DISK"; } | fdisk "$OS_DISK";

View file

@ -1,31 +1,31 @@
#!/bin/bash #!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null; pushd "${BASH_SOURCE%/*}" > /dev/null;
source "../../Common/Scripts/is-truthy.sh"; source "../Scripts/is-truthy.sh";
source "../../Common/Scripts/choose-disk.sh"; source "../Scripts/choose-disk.sh";
ARCH_DISK="${ARCH_DISK}"; OS_DISK="${OS_DISK}";
SKIP_FORMAT_EFI="${SKIP_FORMAT_EFI}"; SKIP_FORMAT_EFI="${SKIP_FORMAT_EFI}";
PARTITION_SCRIPT="${PARTITION_SCRIPT:-"./default-partition.sh"}"; PARTITION_SCRIPT="${PARTITION_SCRIPT:-"./default-partition.sh"}";
memory="$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }')"; memory="$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }')";
swapSize="$(echo "$memory" | awk '{ print int((($1 / 1024 / 1024) * 0.75) + 0.5)}')"; swapSize="$(echo "$memory" | awk '{ print int((($1 / 1024 / 1024) * 0.75) + 0.5)}')";
export SWAP_SIZE="$swapSize"; if [ ! -z "$OS_DISK" ] && [ ! -e "$OS_DISK" ]
if [ ! -z "$ARCH_DISK" ] && [ ! -e "$ARCH_DISK" ]
then then
ARCH_DISK="/dev/${ARCH_DISK}" OS_DISK="/dev/${OS_DISK}"
fi; fi;
if [ -z "$ARCH_DISK" ] || [ ! -e "$ARCH_DISK" ] if [ -z "$OS_DISK" ] || [ ! -e "$OS_DISK" ]
then then
chooseDisk ARCH_DISK "Which disk do you wish to format for installing Arch?"; chooseDisk OS_DISK "Which disk do you wish to format for installing the OS?";
fi; fi;
. "$PARTITION_SCRIPT"; OS_DISK="${OS_DISK}" \
SWAP_SIZE="$swapSize" \
. "$PARTITION_SCRIPT";
while true while true
do do
disks=($(bash -c "echo $ARCH_DISK*")); disks=($(bash -c "echo $OS_DISK*"));
[ "${#disks[@]}" -ge 4 ] && break; [ "${#disks[@]}" -ge 4 ] && break;
done; done;