mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
'added some raid and menu entries, not yet functional'
This commit is contained in:
parent
6ae9d8ba5d
commit
99ca25e643
1 changed files with 1720 additions and 1553 deletions
|
@ -468,6 +468,127 @@ _stopmd()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Disable all software lvm devices
|
||||||
|
_stoplvm()
|
||||||
|
{
|
||||||
|
if [ "$(cat /proc/mdstat | grep ^md)" ]; then
|
||||||
|
DIALOG --infobox "Disabling all software raid devices..." 0 0
|
||||||
|
for i in $(cat /proc/mdstat | grep ^md | sed -e 's# :.*##g'); do
|
||||||
|
mdadm --manage --stop /dev/$i
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Creates software raid devices
|
||||||
|
_createmd()
|
||||||
|
{
|
||||||
|
while [ "$MDFINISH" != "DONE" ]; do
|
||||||
|
: >/tmp/.raid
|
||||||
|
: >/tmp/.raid-spare
|
||||||
|
#
|
||||||
|
# Select raid devices
|
||||||
|
#
|
||||||
|
DIALOG --msgbox "Available partitions:\n\n$(_getavailpartitions)\n" 0 0
|
||||||
|
PARTS=$(findpartitions _)
|
||||||
|
DIALOG --menu "Select the partition to use as first device" 21 50 13 $PARTS 2>$ANSWER || return 1
|
||||||
|
PART=$(cat $ANSWER)
|
||||||
|
echo "$PART" >>/tmp/.raid
|
||||||
|
while [ "$PART" != "DONE" ]; do
|
||||||
|
PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")"
|
||||||
|
DIALOG --menu "Select the partition to use as additional device" 21 50 13 $PARTS SPARE - NONE - DONE _ 2>$ANSWER || return 1
|
||||||
|
PART=$(cat $ANSWER)
|
||||||
|
if [ "$PART" = "NONE" ]; then
|
||||||
|
DIALOG --yesno "Would you like to create a degraded raid on $RAIDDEVICE?" 0 0 && DEGRADED="missing"
|
||||||
|
echo "$DEGRADED" >>/tmp/.raid
|
||||||
|
else
|
||||||
|
if [ "$PART" = "SPARE" ]; then
|
||||||
|
echo "$PART" >>/tmp/.raid-spare
|
||||||
|
else
|
||||||
|
echo "$PART" >>/tmp/.raid
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$(cat /tmp/.raid | grep -v missing | wc -l)" -gt 1 ]; then
|
||||||
|
DIALOG --menu "Select the raid level you want to use" 21 50 13 raid0 - raid1 - raid5 - 2>$ANSWER || return 1
|
||||||
|
LEVEL=$(cat $ANSWER)
|
||||||
|
else
|
||||||
|
DIALOG --menu "Only raid1 level available, too many missing devices." 21 50 13 raid1 - 2>$ANSWER || return 1
|
||||||
|
LEVEL=$(cat $ANSWER)
|
||||||
|
fi
|
||||||
|
DIALOG --yesno "Would you like to create $RAIDDEVICE like this?\n\nLEVEL:$LEVEL\nDEVICES:\n$(for i in $(cat /tmp/.raid); do echo "$i\n";done)" 0 0 && MDFINISH="DONE"
|
||||||
|
done
|
||||||
|
# writing correct raid information to partition table
|
||||||
|
for i in $(cat /tmp/.raid | grep -v missing); do
|
||||||
|
k=$(echo $i | sed -e 's#[0-9]##g')
|
||||||
|
l=$(echo $i | sed -e 's#.*[a-z]##g')
|
||||||
|
sfdisk --change-id $k $l fd
|
||||||
|
done
|
||||||
|
# create raid device
|
||||||
|
for DEVICES in $(cat /tmp/.raid); do
|
||||||
|
DEVICES=$(echo -n "$DEVICES ")
|
||||||
|
done
|
||||||
|
for SPARES in $(cat /tmp/.raid-spare); do
|
||||||
|
SPARES=$(echo -n "$SPARES ")
|
||||||
|
done
|
||||||
|
RAID_DEVICES="$(cat /tmp/.raid | wc -l)"
|
||||||
|
SPARE_DEVICES="$(cat /tmp/.raid-spare | wc -l)"
|
||||||
|
### TODO parity in raid5 mode
|
||||||
|
mdadm --create $RAIDDEVICE --force --run --level=$LEVEL --raid-devices=$RAID_DEVICES --spare-devices=$SPARE_DEVICES $DEVICES
|
||||||
|
|
||||||
|
PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")"
|
||||||
|
PART_ROOT=$PART
|
||||||
|
# Select root filesystem type
|
||||||
|
DIALOG --menu "Select a filesystem for $PART" 21 50 13 $FSOPTS 2>$ANSWER || return 1
|
||||||
|
FSTYPE=$(cat $ANSWER)
|
||||||
|
DOMKFS="no"
|
||||||
|
DIALOG --yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
|
||||||
|
echo "$PART:$FSTYPE:/:$DOMKFS" >>/tmp/.parts
|
||||||
|
|
||||||
|
#
|
||||||
|
# Additional partitions
|
||||||
|
#
|
||||||
|
DIALOG --menu "Select any additional partitions to mount under your new root (select DONE when finished)" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
|
||||||
|
PART=$(cat $ANSWER)
|
||||||
|
while [ "$PART" != "DONE" ]; do
|
||||||
|
PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")"
|
||||||
|
# Select a filesystem type
|
||||||
|
DIALOG --menu "Select a filesystem for $PART" 21 50 13 $FSOPTS 2>$ANSWER || return 1
|
||||||
|
FSTYPE=$(cat $ANSWER)
|
||||||
|
MP=""
|
||||||
|
while [ "${MP}" = "" ]; do
|
||||||
|
DIALOG --inputbox "Enter the mountpoint for $PART" 8 65 "/boot" 2>$ANSWER || return 1
|
||||||
|
MP=$(cat $ANSWER)
|
||||||
|
if grep ":$MP:" /tmp/.parts; then
|
||||||
|
DIALOG --msgbox "ERROR: You have defined 2 identical mountpoints! Please select another mountpoint." 8 65
|
||||||
|
MP=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
DOMKFS="no"
|
||||||
|
DIALOG --yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
|
||||||
|
echo "$PART:$FSTYPE:$MP:$DOMKFS" >>/tmp/.parts
|
||||||
|
DIALOG --menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
|
||||||
|
PART=$(cat $ANSWER)
|
||||||
|
done
|
||||||
|
DIALOG --yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i\n";done)" 0 0 && MDFINISH="DONE"
|
||||||
|
done
|
||||||
|
|
||||||
|
DIALOG --msgbox "Partitions were successfully mounted." 0 0
|
||||||
|
NEXTITEM="4"
|
||||||
|
S_MKFS=1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Creates software lvm devices
|
||||||
|
_createlvm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Encrypt devices
|
||||||
|
_encrypt()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
autoprepare() {
|
autoprepare() {
|
||||||
# disable all raid devices, else weird things can happen during partitioning!
|
# disable all raid devices, else weird things can happen during partitioning!
|
||||||
_stopmd
|
_stopmd
|
||||||
|
@ -685,7 +806,7 @@ mountpoints() {
|
||||||
DIALOG --msgbox "You have already prepared your filesystems with Auto-prepare" 0 0
|
DIALOG --msgbox "You have already prepared your filesystems with Auto-prepare" 0 0
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
while [ "$PARTFINISH" != "DONE" ]; do
|
while [ "$MDFINISH" != "DONE" ]; do
|
||||||
: >/tmp/.fstab
|
: >/tmp/.fstab
|
||||||
: >/tmp/.parts
|
: >/tmp/.parts
|
||||||
FSOPTS=""
|
FSOPTS=""
|
||||||
|
@ -748,7 +869,7 @@ mountpoints() {
|
||||||
DIALOG --menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
|
DIALOG --menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
|
||||||
PART=$(cat $ANSWER)
|
PART=$(cat $ANSWER)
|
||||||
done
|
done
|
||||||
DIALOG --yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i\n";done)" 0 0 && PARTFINISH="DONE"
|
DIALOG --yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i\n";done)" 0 0 && MDFINISH="DONE"
|
||||||
done
|
done
|
||||||
# disable swap and all mounted partitions
|
# disable swap and all mounted partitions
|
||||||
_umountall
|
_umountall
|
||||||
|
@ -1616,8 +1737,9 @@ prepare_harddrive()
|
||||||
dialog $DEFAULT --backtitle "$TITLE" --menu "Prepare Hard Drive" 12 60 5 \
|
dialog $DEFAULT --backtitle "$TITLE" --menu "Prepare Hard Drive" 12 60 5 \
|
||||||
"1" "Auto-Prepare (erases the ENTIRE hard drive)" \
|
"1" "Auto-Prepare (erases the ENTIRE hard drive)" \
|
||||||
"2" "Partition Hard Drives" \
|
"2" "Partition Hard Drives" \
|
||||||
"3" "Set Filesystem Mountpoints" \
|
"3" "Create Raid,Lvm and Encrypt" \
|
||||||
"4" "Return to Main Menu" 2>$ANSWER || CANCEL="1"
|
"4" "Set Filesystem Mountpoints" \
|
||||||
|
"5" "Return to Main Menu" 2>$ANSWER || CANCEL="1"
|
||||||
NEXTITEM="$(cat $ANSWER)"
|
NEXTITEM="$(cat $ANSWER)"
|
||||||
[ "$S_MKFSAUTO" = "1" ] && DONE=1
|
[ "$S_MKFSAUTO" = "1" ] && DONE=1
|
||||||
case $(cat $ANSWER) in
|
case $(cat $ANSWER) in
|
||||||
|
@ -1628,7 +1750,9 @@ prepare_harddrive()
|
||||||
"2")
|
"2")
|
||||||
partition ;;
|
partition ;;
|
||||||
"3")
|
"3")
|
||||||
PARTFINISH=""
|
create_special ;;
|
||||||
|
"4")
|
||||||
|
MDFINISH=""
|
||||||
mountpoints ;;
|
mountpoints ;;
|
||||||
*)
|
*)
|
||||||
DONE=1 ;;
|
DONE=1 ;;
|
||||||
|
@ -1641,6 +1765,47 @@ prepare_harddrive()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# menu for raid, lvm and encrypt
|
||||||
|
prepare_special()
|
||||||
|
{
|
||||||
|
NEXTITEM=""
|
||||||
|
DONE=0
|
||||||
|
#DIALOG --yesno "Do you want to use UUID device name scheme,\ninstead of kernel device name scheme?" 0 0 && UUIDPARAMETER=yes
|
||||||
|
while [ "$DONE" = "0" ]; do
|
||||||
|
if [ -n "$NEXTITEM" ]; then
|
||||||
|
DEFAULT="--default-item $NEXTITEM"
|
||||||
|
else
|
||||||
|
DEFAULT=""
|
||||||
|
fi
|
||||||
|
CANCEL=""
|
||||||
|
dialog $DEFAULT --backtitle "$TITLE" --menu "Create Raid,Lvm and Encrypt" 12 60 5 \
|
||||||
|
"1" "Create Software Raid" \
|
||||||
|
"2" "Create LVM" \
|
||||||
|
"3" "Encrypt" \
|
||||||
|
"4" "Return to Main Menu" 2>$ANSWER || CANCEL="1"
|
||||||
|
NEXTITEM="$(cat $ANSWER)"
|
||||||
|
[ "$S_MKFSAUTO" = "1" ] && DONE=1
|
||||||
|
case $(cat $ANSWER) in
|
||||||
|
"1")
|
||||||
|
_createmd
|
||||||
|
;;
|
||||||
|
"2")
|
||||||
|
_createlvm
|
||||||
|
;;
|
||||||
|
"3")
|
||||||
|
_encrypt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
DONE=1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ "$CANCEL" = "1" ]; then
|
||||||
|
NEXTITEM="3"
|
||||||
|
else
|
||||||
|
NEXTITEM="4"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
do_pacmanmirror()
|
do_pacmanmirror()
|
||||||
{
|
{
|
||||||
SAMEMIRROR=""
|
SAMEMIRROR=""
|
||||||
|
@ -1956,3 +2121,5 @@ done
|
||||||
|
|
||||||
clear
|
clear
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
# vim: set ts=4 sw=4 et:
|
Loading…
Reference in a new issue