天天看點

ProxmoxVE 6.4-13 (PVE) 添加自定義服務

linux的服務管理-systemd,它不是一個指令,而是一組指令,是最新的初始化系統,為系統的啟動和管理提供一套完整的解決方案

關于systemd請看這裡:Systemd 入門教程:實戰篇 - 阮一峰的網絡日志

開啟SR-IOV并且直通進iKuai和openwrt之後,需要用腳本使SR-IOV在虛拟機自啟之前配置完成

寫一個service檔案放在/etc/systemd/system/下

[email protected]:~# cat /etc/systemd/system/sriov.service 
[Unit]
Description=Script to enable SR-IOV on boot

[Service]
Type=simple
#start SR-IOV
ExecStartPre=/usr/bin/bash -c '/usr/bin/echo 3 > /sys/class/net/enp1s0f0/device/sriov_numvfs'
ExecStartPre=/usr/bin/bash -c '/usr/bin/ip link set enp1s0f0 up'
ExecStartPre=/usr/bin/bash -c '/usr/bin/ip link set enp1s0f1 up'
ExecStartPre=/usr/bin/bash -c '/usr/bin/ip link set enp1s0f0v0 address 24:8a:07:b7:a8:70 up'
ExecStartPre=/usr/bin/bash -c '/usr/bin/ip link set enp1s0f0v1 address 24:8a:07:b7:a8:71 up'
ExecStart=/usr/bin/bash -c '/usr/bin/ip link set enp1s0f0v2 address 24:8a:07:b7:a8:72 up'
Restart=on-failure
[Install]
WantedBy=multi-user.target
           

然後執行systemctl deamon-reload

systemctl enable sriov.service

重新開機

PS:過多次嘗試,兩個VM均需配置一定的啟動延遲

但實際不論啟動延遲配置為多少,systemctl status sriov.service顯示的執行完畢時間永遠隻比VM的啟動時間早3-4s

繼續閱讀