mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
start adding multi bcachefs devices
This commit is contained in:
parent
5720f589d5
commit
f6461ec15b
1 changed files with 36 additions and 30 deletions
|
@ -2,40 +2,7 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||||
|
|
||||||
# select bcfs raid devices
|
_bcfs_raid_options() {
|
||||||
_bcfs_select_raid_devices () {
|
|
||||||
# select the second device to use, no missing option available!
|
|
||||||
: >/tmp/.bcfs-devices
|
|
||||||
echo "${_BCFS_DEV}" >>/tmp/.bcfs-devices
|
|
||||||
_BCFS_DEVS=""
|
|
||||||
_DUR_COUNT="0"
|
|
||||||
_BCFS_HDD_COUNT="0"
|
|
||||||
_BCFS_SSD_COUNT="0"
|
|
||||||
#shellcheck disable=SC2001,SC2086
|
|
||||||
for i in ${_DEVS}; do
|
|
||||||
echo "${i}" | grep -q /dev && _BCFS_DEVS="${_BCFS_DEVS} ${i} _ "
|
|
||||||
done
|
|
||||||
_BCFS_DEVS=${_BCFS_DEVS//${_BCFS_DEV}\ _/}
|
|
||||||
_RAIDNUMBER=1
|
|
||||||
while [[ "${_BCFS_DEV}" != "DONE" ]]; do
|
|
||||||
_BCFS_DONE=""
|
|
||||||
_RAIDNUMBER=$((_RAIDNUMBER + 1))
|
|
||||||
# RAID5 needs 3 devices
|
|
||||||
# RAID6 and RAID10 need 4 devices!
|
|
||||||
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 1))" &&\
|
|
||||||
! "${_BCFS_LEVEL}" == "raid10" && ! "${_BCFS_LEVEL}" == "raid6" &&\
|
|
||||||
! "${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _"
|
|
||||||
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 2))" &&\
|
|
||||||
"${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _"
|
|
||||||
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 3))" &&\
|
|
||||||
"${_BCFS_LEVEL}" == "raid10" || "${_BCFS_LEVEL}" == "raid6" ]] && _BCFS_DONE="DONE _"
|
|
||||||
# clean loop from used partition and options
|
|
||||||
_BCFS_DEVS=${_BCFS_DEVS//${_BCFS_DEV}\ _/}
|
|
||||||
# add more devices
|
|
||||||
#shellcheck disable=SC2086
|
|
||||||
_dialog --title " Device ${_RAIDNUMBER} " --no-cancel --menu "" 12 50 6 ${_BCFS_DEVS} ${_BCFS_DONE} 2>"${_ANSWER}" || return 1
|
|
||||||
_BCFS_DEV=$(cat "${_ANSWER}")
|
|
||||||
[[ "${_BCFS_DEV}" == "DONE" ]] && break
|
|
||||||
# add durability
|
# add durability
|
||||||
_BCFS_DURABILITY="1 Normal_Device 0 Cache_Device Custom _"
|
_BCFS_DURABILITY="1 Normal_Device 0 Cache_Device Custom _"
|
||||||
_dialog --no-cancel --title " Durability " --menu "" 13 50 7 ${_BCFS_DURABILITY} 2>"${_ANSWER}" || return 1
|
_dialog --no-cancel --title " Durability " --menu "" 13 50 7 ${_BCFS_DURABILITY} 2>"${_ANSWER}" || return 1
|
||||||
|
@ -63,6 +30,40 @@ _bcfs_select_raid_devices () {
|
||||||
_BCFS_LABEL="--label hdd.${_BCFS_HDD_COUNT}"
|
_BCFS_LABEL="--label hdd.${_BCFS_HDD_COUNT}"
|
||||||
_BCFS_HDD_OPTIONS="--background_target=hdd"
|
_BCFS_HDD_OPTIONS="--background_target=hdd"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# select bcfs raid devices
|
||||||
|
_bcfs_select_raid_devices () {
|
||||||
|
# select the second device to use, no missing option available!
|
||||||
|
: >/tmp/.bcfs-devices
|
||||||
|
echo "${_BCFS_DEV}" >>/tmp/.bcfs-devices
|
||||||
|
_BCFS_DEVS=""
|
||||||
|
#shellcheck disable=SC2001,SC2086
|
||||||
|
for i in ${_DEVS}; do
|
||||||
|
echo "${i}" | grep -q /dev && _BCFS_DEVS="${_BCFS_DEVS} ${i} _ "
|
||||||
|
done
|
||||||
|
_BCFS_DEVS=${_BCFS_DEVS//${_BCFS_DEV}\ _/}
|
||||||
|
_RAIDNUMBER=1
|
||||||
|
while [[ "${_BCFS_DEV}" != "DONE" ]]; do
|
||||||
|
_BCFS_DONE=""
|
||||||
|
_RAIDNUMBER=$((_RAIDNUMBER + 1))
|
||||||
|
# RAID5 needs 3 devices
|
||||||
|
# RAID6 and RAID10 need 4 devices!
|
||||||
|
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 1))" &&\
|
||||||
|
! "${_BCFS_LEVEL}" == "raid10" && ! "${_BCFS_LEVEL}" == "raid6" &&\
|
||||||
|
! "${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _"
|
||||||
|
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 2))" &&\
|
||||||
|
"${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _"
|
||||||
|
[[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 3))" &&\
|
||||||
|
"${_BCFS_LEVEL}" == "raid10" || "${_BCFS_LEVEL}" == "raid6" ]] && _BCFS_DONE="DONE _"
|
||||||
|
# clean loop from used partition and options
|
||||||
|
_BCFS_DEVS=${_BCFS_DEVS//${_BCFS_DEV}\ _/}
|
||||||
|
# add more devices
|
||||||
|
#shellcheck disable=SC2086
|
||||||
|
_dialog --title " Device ${_RAIDNUMBER} " --no-cancel --menu "" 12 50 6 ${_BCFS_DEVS} ${_BCFS_DONE} 2>"${_ANSWER}" || return 1
|
||||||
|
_BCFS_DEV=$(cat "${_ANSWER}")
|
||||||
|
[[ "${_BCFS_DEV}" == "DONE" ]] && break
|
||||||
|
_bcfs_raid_options || return 1
|
||||||
echo "${_DURABILITY}" "${_BCFS_LABEL}" "${_BCFS_DEV}" >>/tmp/.bcfs-devices
|
echo "${_DURABILITY}" "${_BCFS_LABEL}" "${_BCFS_DEV}" >>/tmp/.bcfs-devices
|
||||||
done
|
done
|
||||||
# final step ask if everything is ok?
|
# final step ask if everything is ok?
|
||||||
|
@ -76,6 +77,9 @@ _bcfs_raid_level() {
|
||||||
_BCFS_RAID_FINISH=""
|
_BCFS_RAID_FINISH=""
|
||||||
_BCFS_LEVEL=""
|
_BCFS_LEVEL=""
|
||||||
_BCFS_DEV="${_DEV}"
|
_BCFS_DEV="${_DEV}"
|
||||||
|
_DUR_COUNT="0"
|
||||||
|
_BCFS_HDD_COUNT="0"
|
||||||
|
_BCFS_SSD_COUNT="0"
|
||||||
: >/tmp/.bcfs-devices
|
: >/tmp/.bcfs-devices
|
||||||
while [[ "${_BCFS_RAID_FINISH}" != "DONE" ]]; do
|
while [[ "${_BCFS_RAID_FINISH}" != "DONE" ]]; do
|
||||||
#shellcheck disable=SC2086
|
#shellcheck disable=SC2086
|
||||||
|
@ -88,12 +92,14 @@ _bcfs_raid_level() {
|
||||||
# replicas
|
# replicas
|
||||||
_BCFS_REPLICATION="2 - 3 - Custom _"
|
_BCFS_REPLICATION="2 - 3 - Custom _"
|
||||||
_dialog --no-cancel --title " Replication Level " --menu "" 13 50 7 ${_BCFS_REPLICATION} 2>"${_ANSWER}" || return 1
|
_dialog --no-cancel --title " Replication Level " --menu "" 13 50 7 ${_BCFS_REPLICATION} 2>"${_ANSWER}" || return 1
|
||||||
|
|
||||||
_BCFS_REP_COUNT="$(cat ${_ANSWER})"
|
_BCFS_REP_COUNT="$(cat ${_ANSWER})"
|
||||||
if [[ ${_BCFS_REPLICATION} == "Custom" ]]; then
|
if [[ ${_BCFS_REPLICATION} == "Custom" ]]; then
|
||||||
_dialog --inputbox "Enter custom replication level (number):" 8 65 \
|
_dialog --inputbox "Enter custom replication level (number):" 8 65 \
|
||||||
"4" 2>"${_ANSWER}" || return 1
|
"4" 2>"${_ANSWER}" || return 1
|
||||||
_BCFS_REPLICATION=$(cat "${_ANSWER}")
|
_BCFS_REPLICATION=$(cat "${_ANSWER}")
|
||||||
fi
|
fi
|
||||||
|
_bcfs_raid_options
|
||||||
_bcfs_select_raid_devices
|
_bcfs_select_raid_devices
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue