48 lines
1.1 KiB
Bash
Executable file
48 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
pushd "${BASH_SOURCE%/*}" > /dev/null;
|
|
|
|
source "../../Common/Scripts/is-truthy.sh";
|
|
source "../../Common/Scripts/choose-disk.sh";
|
|
ARCH_DISK="${ARCH_DISK}";
|
|
SKIP_FORMAT_EFI="${SKIP_FORMAT_EFI}";
|
|
PARTITION_SCRIPT="${PARTITION_SCRIPT:-"./default-partition.sh"}";
|
|
memory="$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }')";
|
|
swapSize="$(echo "$memory" | awk '{ print int(($1 / 1024 / 1024 4) + 0.5)}')";
|
|
|
|
export SWAP_SIZE="$swapSize";
|
|
|
|
if [ ! -z "$ARCH_DISK" ] && [ ! -e "$ARCH_DISK" ]
|
|
then
|
|
ARCH_DISK="/dev/${ARCH_DISK}"
|
|
fi;
|
|
|
|
if [ -z "$ARCH_DISK" ] || [ ! -e "$ARCH_DISK" ]
|
|
then
|
|
chooseDisk ARCH_DISK "Which disk do you wish to format for installing Arch?";
|
|
fi;
|
|
|
|
. "$PARTITION_SCRIPT";
|
|
|
|
while true
|
|
do
|
|
disks=($(bash -c "echo $ARCH_DISK*"));
|
|
[ "${#disks[@]}" -ge 4 ] && break;
|
|
done;
|
|
|
|
bootDisk="${BOOT_DISK:-"${disks[1]}"}";
|
|
swapDisk="${SWAP_DISK:-"${disks[2]}"}";
|
|
linuxDisk="${LINUX_DISK:-"${disks[3]}"}";
|
|
|
|
if ! isTruthy "$SKIP_FORMAT_EFI"
|
|
then
|
|
mkfs.fat -F 32 "$bootDisk";
|
|
fi
|
|
|
|
mkswap "$swapDisk";
|
|
mkfs.ext4 -F "$linuxDisk";
|
|
|
|
mount "$linuxDisk" /mnt;
|
|
mount --mkdir "$bootDisk" /mnt/boot;
|
|
swapon "$swapDisk";
|
|
|
|
popd > /dev/null;
|