過去幾個小時我一直在為這件事傷透腦筋。在我的一台機器上,intel-rapl-msr
驅動程式有問題,重新載入即可解決問題。我想我可以輕鬆地創建一個在啟動時執行此操作的服務。但在驅動程式載入後我無法載入服務。
[Unit]
Description=Reload intel-rapl-msr
Requires=systemd-modules-load.target
WantedBy=multi-user.target
ExecStart=/nix/store/wqjkhyyffqdbx767vlqklzi12ln8j3pv-unit-script-cpu-script-start/bin/cpu-script-start
其中腳本ExecStart
僅包含:
rmmod intel_rapl_msr
modprobe intel_rapl_msr
這樣,服務在啟動時就會失敗,並顯示以下訊息:
mmod: ERROR: Module intel_rapl_msr is not currently loaded
那麼是否可以在載入該核心模組後強制執行某個服務呢?
任何幫助表示讚賞!
答案1
我解決了服務的模組依賴性,我開始使用 systemd-modules-load.service 來載入這些模組
實際上:將模組加入到:/etc/modules-load.d/modules.conf
https://www.freedesktop.org/software/systemd/man/modules-load.d.html#
答案2
所以現在我只是用lsmod
它進行輪詢,但它有點髒:
while ! lsmod | grep -q intel_rapl_msr;
do
echo "intel_rapl_msr not loaded yet... sleeping for 5 seconds"
sleep 5
done
echo "found intel_rapl_msr"
rmmod intel_rapl_msr
modprobe intel_rapl_msr