rmmod net and drm driver before kexec

This commit is contained in:
Ing 2024-07-26 15:32:16 +08:00
parent 740143089c
commit fbc24e0517

View File

@ -12,19 +12,6 @@ loaderIsConfigured || die "$(TEXT "Loader is not configured!")"
# Check if machine has EFI # Check if machine has EFI
[ -d /sys/firmware/efi ] && EFI=1 || EFI=0 [ -d /sys/firmware/efi ] && EFI=1 || EFI=0
# Proc open nvidia driver when booting
NVPCI_ADDR=$(lspci -nd 10de: | grep -e 0300 -e 0302 | awk '{print $1}')
if [ -n "${NVPCI_ADDR}" ]; then
modprobe -r nouveau || true
NVDEV_PATH=$(find /sys/devices -name *${NVPCI_ADDR} | grep -v supplier)
for DEV_PATH in ${NVDEV_PATH}
do
if [ -e ${DEV_PATH}/reset ]; then
echo 1 > ${DEV_PATH}/reset || true
fi
done
fi
BUS=$(getBus "${LOADER_DISK}") BUS=$(getBus "${LOADER_DISK}")
# Print text centralized # Print text centralized
@ -184,6 +171,9 @@ if [ "${DT}" = "true" ] && ! echo "epyc7002 purley broadwellnkv2" | grep -wq "${
fi fi
fi fi
# CMDLINE['kvm.ignore_msrs']="1"
# CMDLINE['kvm.report_ignored_msrs']="0"
if echo "apollolake geminilake" | grep -wq "${PLATFORM}"; then if echo "apollolake geminilake" | grep -wq "${PLATFORM}"; then
CMDLINE["intel_iommu"]="igfx_off" CMDLINE["intel_iommu"]="igfx_off"
fi fi
@ -332,6 +322,17 @@ else
# Clear logs for dbgutils addons # Clear logs for dbgutils addons
rm -rf "${PART1_PATH}/logs" >/dev/null 2>&1 || true rm -rf "${PART1_PATH}/logs" >/dev/null 2>&1 || true
# Unload all network interfaces
for D in $(readlink /sys/class/net/*/device/driver); do rmmod -f "$(basename ${D})" 2>/dev/null || true; done
# Unload all graphics drivers
# for D in $(readlink /sys/class/drm/*/device/driver); do rmmod -f "$(basename ${D})" 2>/dev/null || true; done
for D in $(lsmod | grep -E '^(nouveau|amdgpu|radeon|i915)' | awk '{print $1}'); do rmmod -f "${D}" 2>/dev/null || true; done
for I in $(find /sys/devices -name uevent -exec bash -c 'cat {} 2>/dev/null | grep -Eq "PCI_CLASS=0?30[0|1|2]00" && dirname {}' \;); do
[ -e ${I}/reset ] && cat ${I}/vendor >/dev/null | grep -iq 0x10de && echo 1 >${I}/reset || true # Proc open nvidia driver when booting
done
# Reboot
KERNELWAY="$(readConfigKey "kernelway" "${USER_CONFIG_FILE}")" KERNELWAY="$(readConfigKey "kernelway" "${USER_CONFIG_FILE}")"
[ "${KERNELWAY}" = "kexec" ] && kexec -a -e || poweroff [ "${KERNELWAY}" = "kexec" ] && kexec -a -e || poweroff
exit 0 exit 0