#!/bash
+#########################################################
+## Allow manual partitioning when installing instantOS ##
+## Supports editing partitions and using existing ones ##
+#########################################################
+
+# todo: warning and confirmation messages
+
source /root/instantARCH/askutils.sh
+# first displayed menu
startchoice() {
STARTCHOICE="$(echo 'edit partitions
choose partitions
chooseparts
;;
esac
-
}
+# cfdisk wrapper to modify partition table during installation
editparts() {
DISK="$(fdisk -l | grep -i '^Disk /.*:' | imenu -l 'choose disk to edit> ')"
startchoice
}
+# choose all partitions
chooseparts() {
choosehome
}
+# menu that allows choosing a partition and put it in stdout
choosepart() {
unset RETURNPART
while [ -z "$RETURNPART" ]; do
echo "$RETURNPART"
}
+# choose home partition, allow using existing content or reformatting
choosehome() {
+ if ! imenu -c "do you want to use a seperate home partition?"; then
+ return
+ fi
+
HOMEPART="$(choosepart 'choose home partition >')"
case "$(echo 'keep current home data
erase partition to start fresh' | imenu -l)" in
}
+# choose swap partition or swap file
chooseswap() {
case "$(echo 'use a swap file
use a swap partition' | imenu -l)" in
esac
}
+# choose root partition for programs etc
chooseroot() {
+ while [ -z "$ROOTCONFIRM" ]; do
+ PARTROOT="$(choosepart 'choose root partition')"
+ imenu -c "This will erase all data on that partition. Continue?" &&
+ ROOTCONFIRM="true"
+ echo "$PARTROOT" >/root/instantARCH/config/partroot
+ done
+}
+# //weiter
+choosegrub() {
+ if efibootmgr; then
+ echo "efi setup detected"
+ choosepart 'select efi partition'
+ else
+
+ fi
}
#!/bin/bash
-# automatic disk partitioning
+IROOT="/root/instantARCH/config"
-DISK=$(cat /root/instantARCH/config/disk)
+if ! [ -e /opt/instantARCH/config/manualpartitioning ]; then
+ # automatic disk partitioning
-if efibootmgr; then
- echo "efi system"
- echo "label: dos
+ DISK=$(cat /root/instantARCH/config/disk)
+
+ if efibootmgr; then
+ echo "efi system"
+ echo "label: dos
start= 4096, size= 614400, type=ef
start=618496, type=83, bootable" | sfdisk "${DISK}"
- DISK1=$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | head -1)
- DISK2=$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | tail -1)
+ DISK1=$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | head -1)
+ DISK2=$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | tail -1)
- mkfs.fat -F32 "$DISK1"
- mkfs.ext4 -F "$DISK2"
+ mkfs.fat -F32 "$DISK1"
+ mkfs.ext4 -F "$DISK2"
- echo "$DISK1" >/root/instantARCH/config/partefi
- echo "$DISK2" >/root/instantARCH/config/partroot
+ echo "$DISK1" >/root/instantARCH/config/partefi
+ echo "$DISK2" >/root/instantARCH/config/partroot
-else
- echo "legacy bios"
- echo "label: dos
+ else
+ echo "legacy bios"
+ echo "label: dos
type=83, bootable" | sfdisk "${DISK}"
- DISK1="$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | head -1)"
+ DISK1="$(fdisk -l | grep "^${DISK}" | grep -o '^[^ ]*' | head -1)"
- mkfs.ext4 -F "$DISK1"
- echo "$DISK1" >/root/instantARCH/config/partroot
+ mkfs.ext4 -F "$DISK1"
+ echo "$DISK1" >/root/instantARCH/config/partroot
+
+ fi
+else
+ # //weiter
+ echo "doing manual partitioning"
+ if [ -e "$IROOT/parthome" ] && [ -e "$IROOT/erasehome" ]; then
+ echo "creating ext4 file system for home in $(cat $IROOT/parthome)"
+ mkfs.ext4 "$(cat $IROOT/parthome)"
+ fi
+
+ if [ -e "$IROOT/partswap" ]; then
+ echo "creating swap"
+ mkswap "$(cat $IROOT/partswap)"
+ fi
+
+ mkfs.ext4 "$(cat $IROOT/partroot)"
fi