disks: update

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-06-29 16:47:26 +02:00
parent 5e36906379
commit 2a272fe20c

View File

@ -169,14 +169,17 @@ function dtModel() {
I=1
for P in $(lspci -d ::106 2>/dev/null | cut -d' ' -f1); do
HOSTNUM=$(ls -l /sys/class/scsi_host 2>/dev/null | grep ${P} | wc -l)
PCIHEAD="$(ls -l /sys/class/scsi_host 2>/dev/null | grep ${P} | head -1)"
PCIPATH=""
for Q in $(ls -l /sys/class/scsi_host 2>/dev/null | grep ${P} | head -1 | grep -oE ":..\.."); do PCIPATH="${PCIPATH},${Q//:/}"; done
[ -z "${PCIPATH}" ] && continue
if [ "$(_kernelVersionCode "$(_kernelVersion)")" -ge "$(_kernelVersionCode "5.10")" ]; then
PCIPATH="0000:00:${PCIPATH:1}" # 5.10+ kernel TODO: check 0000
PCIPATH="$(echo "${PCIHEAD}" | grep -oP 'pci\K[0-9]{4}:[0-9]{2}')" # 5.10+ kernel
else
PCIPATH="00:${PCIPATH:1}" # 5.10- kernel
PCIPATH="$(echo "${PCIHEAD}" | grep -oP 'pci\K[0-9]{4}:[0-9]{2}' | cut -d':' -f2)" # 5.10- kernel
fi
PCISUBS=""
for Q in $(echo "${PCIHEAD}" | grep -oE ":..\.."); do PCISUBS="${PCISUBS},${Q//:/}"; done
[ -z "${PCISUBS}" ] && continue
PCIPATH="${PCIPATH}:${PCISUBS:1}"
IDX=""
if [ -n "${BOOTDISK_PHYSDEVPATH}" ] && echo "${BOOTDISK_PHYSDEVPATH}" | grep -q "${P}"; then
@ -205,8 +208,8 @@ function dtModel() {
if [ -n "${BOOTDISK_PHYSDEVPATH}" -a "${BOOTDISK_PHYSDEVPATH}" = "$(cat /sys/block/sata${J}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'=' -f2)" ]; then
echo "bootloader: /sys/block/sata${J}"
else
PCIEPATH=$(grep 'pciepath' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)
ATAPORT=$(grep 'ata_port_no' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)
PCIEPATH="$(grep 'pciepath' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)"
ATAPORT="$(grep 'ata_port_no' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)"
if [ -n "${PCIEPATH}" -a -n "${ATAPORT}" ]; then
echo " internal_slot@${I} {" >>${DEST}
echo " protocol_type = \"sata\";" >>${DEST}
@ -230,8 +233,8 @@ function dtModel() {
if [ -n "${BOOTDISK_PHYSDEVPATH}" -a "${BOOTDISK_PHYSDEVPATH}" = "$(cat /sys/block/sata${J}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'=' -f2)" ]; then
echo "bootloader: /sys/block/sata${J}"
else
PCIEPATH=$(grep 'pciepath' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)
ATAPORT=$(grep 'ata_port_no' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)
PCIEPATH="$(grep 'pciepath' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)"
ATAPORT="$(grep 'ata_port_no' /sys/block/sata${J}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)"
if [ -n "${PCIEPATH}" -a -n "${ATAPORT}" ]; then
echo " internal_slot@${I} {" >>${DEST}
echo " protocol_type = \"sata\";" >>${DEST}
@ -271,14 +274,16 @@ function dtModel() {
echo "bootloader: ${P}"
continue
fi
PCIEPATH=$(grep 'pciepath' ${P}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)
PCIEPATH="$(grep 'pciepath' ${P}/device/syno_block_info 2>/dev/null | cut -d'=' -f2)"
if [ -n "${PCIEPATH}" ]; then
grep -q "pcie_root = \"${PCIEPATH}\";" ${DEST} && continue # An nvme controller only recognizes one disk
[ $((${#POWER_LIMIT} - 1 + 2)) -gt 30 ] && break # POWER_LIMIT string length limit 30 characters
COUNT=$((${COUNT} + 1))
echo " nvme_slot@${COUNT} {" >>${DEST}
echo " pcie_root = \"${PCIEPATH}\";" >>${DEST}
echo " port_type = \"ssdcache\";" >>${DEST}
echo " };" >>${DEST}
POWER_LIMIT="${POWER_LIMIT},100"
POWER_LIMIT="${POWER_LIMIT},0"
fi
done
[ -n "${POWER_LIMIT:1}" ] && sed -i "s/power_limit = .*/power_limit = \"${POWER_LIMIT:1}\";/" ${DEST} || sed -i '/power_limit/d' ${DEST}
@ -344,7 +349,6 @@ function nondtModel() {
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}"
@ -368,7 +372,7 @@ function nondtModel() {
_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
@ -389,14 +393,15 @@ function nondtModel() {
echo "bootloader: ${P}"
continue
fi
PCIEPATH=$(cat ${P}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'/' -f4)
PCIEPATH="$(cat ${P}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'/' -f4)"
if [ -n "${PCIEPATH}" ]; then
# TODO: Need check?
# MULTIPATH=$(cat ${P}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'/' -f5)
# MULTIPATH="$(cat ${P}/uevent 2>/dev/null | grep 'PHYSDEVPATH' | cut -d'/' -f5)"
# if [ -z "${MULTIPATH}" ]; then
# echo "${PCIEPATH} does not support!"
# continue
# fi
grep -q "=\"${PCIEPATH}\"" /etc/extensionPorts && continue # An nvme controller only recognizes one disk
echo "pci${COUNT}=\"${PCIEPATH}\"" >>/etc/extensionPorts
COUNT=$((${COUNT} + 1))