3 #########################################################
4 ## Allow manual partitioning when installing instantOS ##
5 ## Supports editing partitions and using existing ones ##
6 #########################################################
8 # todo: warning and confirmation messages
10 source /root/instantARCH/askutils.sh
12 # first displayed menu
14 STARTCHOICE="$(echo 'edit partitions
16 continue installation' | imenu -l)"
18 case "$STARTCHOICE" in
32 # cfdisk wrapper to modify partition table during installation
34 echo 'instantOS requires the following paritions:
35 - a root partition, all data on it will be erased
36 - an optional home partition.
37 If not specified, the same partition as root will be used.
38 Gives you the option to keep existing data on the partition
39 - an optional swap partition.
40 If not specified a swap file will be used.
41 The Bootloader requires
43 - an EFI partition on uefi systems
44 - a disk to install it to on legacy-bios systems
47 EDITDISK="$(fdisk -l | grep -i '^Disk /.*:' | imenu -l 'choose disk to edit> ' | grep -o '/dev/[^:]*')"
48 echo "editing disk $EDITDISK"
51 if command -v st; then
52 st -e bash -c "cfdisk $EDITDISK"
53 elif command -v urxvt; then
54 urxvt -e bash -c "cfdisk $EDITDISK"
56 xterm -e bash -c "cfdisk $EDITDISK"
62 iroot disk "$EDITDISK"
66 # choose all partitions
74 # menu that allows choosing a partition and put it in stdout
77 while [ -z "$RETURNPART" ]; do
78 fdisk -l | grep '^/dev' | sed 's/\*/ * /g' | imenu -l "$1" | grep -o '^[^ ]*' >/tmp/diskchoice
79 RETURNPART="$(cat /tmp/diskchoice)"
80 if ! [ -e "$RETURNPART" ]; then
81 imenu -m "$RETURNPART does not exist" &>/dev/null
88 # choose home partition, allow using existing content or reformatting
90 if ! imenu -c "do you want to use a seperate home partition?"; then
94 HOMEPART="$(choosepart 'choose home partition >')"
95 case "$(echo 'keep current home data
96 erase partition to start fresh' | imenu -l)" in
105 iroot parthome "$HOMEPART"
106 echo "$HOMEPART" >/root/instantARCH/config/parthome
110 # choose swap partition or swap file
112 case "$(echo 'use a swap file
113 use a swap partition' | imenu -l)" in
116 echo "using a swap file"
119 echo "using a swap partition"
120 choosepart "choose swap partition> " >/root/instantARCH/config/partswap
126 # choose root partition for programs etc
128 while [ -z "$ROOTCONFIRM" ]; do
129 PARTROOT="$(choosepart 'choose root partition')"
130 if imenu -c "This will erase all data on that partition. Continue?"; then
132 echo "instantOS will be installed on $PARTROOT"
135 echo "$PARTROOT" >/root/instantARCH/config/partroot
139 # choose wether to install grub and where to install it
142 while [ -z $BOOTLOADERCONFIRM ]; do
143 if ! confirm -c "install bootloader (grub) ?"; then
144 if confirm -c "are you sure? This could make the system unbootable. "; then
145 touch /root/instantARCH/config/nobootloader
149 BOOTLOADERCONFIRM="true"
155 while [ -z "$EFICONFIRM" ]; do
156 choosepart 'select efi partition' >/root/instantARCH/config/partefi
157 if imenu -c "this will erase all data on $(cat /root/instantARCH/config/partefi)"; then
160 rm /root/instantARCH/config/partefi
165 GRUBDISK=$(fdisk -l | grep -i '^Disk /.*:' | imenu -l "select disk for grub > " | grep -o '/dev/[^:]*')