disks: try something new

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-05-19 16:34:19 +02:00
parent a1a35e180a
commit 0accbc1ade

View File

@ -255,11 +255,11 @@ function dtModel() {
# [ ${MAXDISKS} -le 2 ] && MAXDISKS=4
[ ${MAXDISKS} -lt 26 ] && MAXDISKS=26
fi
# # Raidtool will read maxdisks, but when maxdisks is greater than 27, formatting error will occur 8%.
# if ! _check_rootraidstatus && [ ${MAXDISKS} -gt 26 ]; then
# MAXDISKS=26
# echo "set maxdisks=26 [${MAXDISKS}]"
# fi
# Raidtool will read maxdisks, but when maxdisks is greater than 27, formatting error will occur 8%.
if ! _check_rootraidstatus && [ ${MAXDISKS} -gt 26 ]; then
MAXDISKS=26
echo "set maxdisks=26 [${MAXDISKS}]"
fi
_set_conf_kv rd "maxdisks" "${MAXDISKS}"
echo "maxdisks=${MAXDISKS}"
@ -313,32 +313,43 @@ function nondtModel() {
ESATAPORTCFG=0
INTERNALPORTCFG=0
USBDISKNUM=0
USBMAXIDX=26
hasUSB=false
USBMINIDX=20
USBMAXIDX=20
for I in $(ls -d /sys/block/sd* 2>/dev/null); do
IDX=$(_atoi ${I/\/sys\/block\/sd/})
[ $((${IDX} + 1)) -gt ${MAXDISKS} ] && MAXDISKS=$((${IDX} + 1))
[ $((${IDX} + 1)) -ge ${MAXDISKS} ] && MAXDISKS=$((${IDX} + 1))
ISUSB="$(cat ${I}/uevent 2>/dev/null | grep PHYSDEVPATH | grep usb)"
if [ -n "${ISUSB}" ]; then
USBDISKNUM=$((${USBDISKNUM} + 1))
([ ${IDX} -lt ${USBMINIDX} ] || [ "${hasUSB}" = "false" ]) && USBMINIDX=${IDX}
([ ${IDX} -gt ${USBMAXIDX} ] || [ "${hasUSB}" = "false" ]) && USBMAXIDX=${IDX}
hasUSB=true
fi
done
#[ ${USBDISKNUM} -lt 6 ] && USBDISKNUM=6 # Define 6 is the minimum number of USB disks
USBMINIDX=$((${USBMAXIDX} - ${USBDISKNUM}))
#[ $((${USBMINIDX} + ${USBDISKNUM})) -gt ${MAXDISKS} ] && MAXDISKS=$((${USBMINIDX} + ${USBDISKNUM}))
# Define 6 is the minimum number of USB disks
if [ "${hasUSB}" = "false" ]; then
USBMINIDX=$((${MAXDISKS} - 1))
USBMAXIDX=$((${USBMINIDX} + 6))
else
[ $((${USBMAXIDX} - ${USBMINIDX})) -lt 6 ] && USBMAXIDX=$((${USBMINIDX} + 6))
fi
[ $((${USBMAXIDX} + 1)) -gt ${MAXDISKS} ] && MAXDISKS=$((${USBMAXIDX} + 1))
if _check_post_k "rd" "maxdisks"; then
MAXDISKS=$(($(_get_conf_kv maxdisks)))
printf "get maxdisks=%d\n" "${MAXDISKS}"
else
# fix isSingleBay issue: if maxdisks is 1, there is no create button in the storage panel
# [ ${MAXDISKS} -le 2 ] && MAXDISKS=4
printf "cal maxdisks=%d\n" "${MAXDISKS}"
fi
if _check_post_k "rd" "usbportcfg"; then
USBPORTCFG=$(($(_get_conf_kv usbportcfg)))
printf 'get usbportcfg=0x%.2x\n' "${USBPORTCFG}"
else
USBPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ $((2 ** ${USBMINIDX} - 1))))
USBPORTCFG=$(($((2 ** $((${USBMAXIDX} + 1)) - 1)) ^ $((2 ** $((${USBMINIDX} + 1)) - 1))))
_set_conf_kv rd "usbportcfg" "$(printf '0x%.2x' ${USBPORTCFG})"
printf 'set usbportcfg=0x%.2x\n' "${USBPORTCFG}"
fi
@ -353,11 +364,16 @@ function nondtModel() {
INTERNALPORTCFG=$(($(_get_conf_kv internalportcfg)))
printf 'get internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}"
else
INTERNALPORTCFG=$((2 ** ${MAXDISKS} - 1))
INTERNALPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ ${USBPORTCFG} ^ ${ESATAPORTCFG}))
_set_conf_kv rd "internalportcfg" "$(printf "0x%.2x" ${INTERNALPORTCFG})"
printf 'set internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}"
fi
# Raidtool will read maxdisks, but when maxdisks is greater than 27, formatting error will occur 8%.
if ! _check_rootraidstatus && [ ${MAXDISKS} -gt 26 ]; then
MAXDISKS=26
printf "set maxdisks=26 [%d]\n" "${MAXDISKS}"
fi
_set_conf_kv rd "maxdisks" "${MAXDISKS}"
printf "set maxdisks=%d\n" "${MAXDISKS}"
@ -413,6 +429,7 @@ elif [ "${1}" = "late" ]; then
if [ "$(_get_conf_kv supportportmappingv2)" = "yes" ]; then
echo "Copying /etc.defaults/model.dtb"
# copy file
cp -vf /usr/bin/dtc /tmpRoot/usr/bin/dtc
cp -vf /etc/model.dtb /tmpRoot/etc/model.dtb
cp -vf /etc/model.dtb /tmpRoot/etc.defaults/model.dtb
else
@ -442,4 +459,4 @@ elif [ "${1}" = "late" ]; then
SUPPORT_M2_POOL=$(_get_conf_kv support_m2_pool)
_set_conf_kv hd "supportnvme" "${SUPPORTNVME}"
_set_conf_kv hd "support_m2_pool" "${SUPPORT_M2_POOL}"
fi
fi