PortValhalla/scripts/Arch/OS/partition.sh

64 lines
1.1 KiB
Bash
Raw Normal View History

pushd "${BASH_SOURCE%/*}" > /dev/null;
2023-04-01 15:08:17 +00:00
source "../../Common/Scripts/choose-disk.sh";
2023-04-01 11:40:52 +00:00
ARCH_DISK="${ARCH_DISK}";
memory="$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }')";
2023-04-01 10:28:53 +00:00
swapSize="$(echo "$memory" | awk '{ print int(($1 / 1024 / 1024 4) + 0.5)}')";
if [ ! -z "$ARCH_DISK" ] && [ ! -e "$ARCH_DISK" ]
then
ARCH_DISK="/dev/${ARCH_DISK}"
fi;
if [ -z "$ARCH_DISK" ] || [ ! -e "$ARCH_DISK" ]
2023-04-01 11:40:52 +00:00
then
chooseDisk ARCH_DISK "Which disk do you wish to format for installing Arch?";
fi;
{
echo "g";
echo "n";
echo "";
echo "";
echo "+1G";
echo "y";
echo "t";
echo "1";
echo "n";
echo "";
echo "";
echo "+${swapSize}G";
echo "y";
echo "t";
2023-04-01 01:15:21 +00:00
echo "";
echo "19";
echo "n";
echo "";
echo "";
echo "";
echo "y";
echo "t";
2023-04-01 01:15:21 +00:00
echo "";
echo "23";
echo "w";
2023-04-01 10:38:15 +00:00
} | fdisk "$ARCH_DISK";
2023-04-01 10:38:15 +00:00
disks=($(bash -c "echo $ARCH_DISK*"));
2023-04-01 01:32:04 +00:00
bootDisk="${disks[1]}";
swapDisk="${disks[2]}";
linuxDisk="${disks[3]}";
2023-04-01 01:30:58 +00:00
mkfs.fat -F 32 "$bootDisk";
mkswap "$swapDisk";
mkfs.ext4 "$linuxDisk";
2023-04-01 01:19:02 +00:00
mount "$linuxDisk" /mnt;
mount --mkdir "$bootDisk" /mnt/boot;
swapon "$swapDisk";
2023-04-01 01:15:32 +00:00
popd > /dev/null;