OSDN Git Service

start manual partitioning
authorpaperbenni <paperbenni@gmail.com>
Sat, 6 Jun 2020 21:35:45 +0000 (23:35 +0200)
committerpaperbenni <paperbenni@gmail.com>
Sat, 6 Jun 2020 21:35:45 +0000 (23:35 +0200)
askdisk.sh
disk/disk.sh
disk/mount.sh

index 4de9844..e9afd20 100644 (file)
@@ -1,7 +1,15 @@
 #!/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
@@ -16,9 +24,9 @@ back' | imenu -l)"
         chooseparts
         ;;
     esac
-
 }
 
+# cfdisk wrapper to modify partition table during installation
 editparts() {
     DISK="$(fdisk -l | grep -i '^Disk /.*:' | imenu -l 'choose disk to edit> ')"
 
@@ -38,10 +46,12 @@ editparts() {
     startchoice
 }
 
+# choose all partitions
 chooseparts() {
     choosehome
 }
 
+# menu that allows choosing a partition and put it in stdout
 choosepart() {
     unset RETURNPART
     while [ -z "$RETURNPART" ]; do
@@ -55,7 +65,12 @@ choosepart() {
     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
@@ -71,6 +86,7 @@ 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
@@ -86,6 +102,22 @@ 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
 }
index 3d9061f..cd02f78 100755 (executable)
@@ -1,31 +1,50 @@
 #!/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
index ae82b09..8c3e8e4 100644 (file)
@@ -13,8 +13,12 @@ mountpart() {
     fi
 }
 
+# todo: optional efi
 mountpart efi /efi
+
 mountpart root /mnt
+# home is optional
+mountpart home /mnt/home
 sleep 2
 
 if ! mount | grep -q '/mnt'; then