第一步:
是要把bios里面远程唤醒功能和PCI启动打开
第二步:
在PVE里面的SHELL或者SSH安装 ethtool 工具,安装命令:
apt-get install ethtool
第三步:
用ethtool工具查看网卡信息,如果是多网卡的话,需要先搞清楚哪个是链接外网的管理口,举例网卡为enp3s0
ethtool enp3s0
找到网卡信息中的supports wake-on和wake-on两个参数,如果supports值为pumbg,表示网卡支持远程唤醒,wake-on的值d表示禁用、g表示开启,默认为d。
第四步:用ethtool开启网卡远程唤醒,把wake-on值改为g
ethtool -s enp3s0 wol g
因为每次重启后会失效,所以我们需要把开启命令写入开机自动执行脚本。
第五步:
编辑 /etc/rc.local文件,写入开机自动执行开启远程唤醒的脚本。
nano /etc/rc.local
插入以下代码后保存重启all done
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. /sbin/ethtool -s enp3s0 wol g exit 0
比较新的Linux发行版已经没有rc.local文件了。因为已经将其服务化了。
解决方法:
1、设置rc-local.service
1
2
3
4
5
6
7
8
9
10
11
12
13
|
sudo vim /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
|
2、激活rc-local.service
1
|
sudo systemctl enable rc-local.service
|
3、添加启动服务
手工创建或者拷贝已有的/etc/rc.local
,并赋予执行权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# 下面这条是要开机启动的命令
/home/selfcs/anaconda3/bin/python /home/selfcs/t.py > /home/selfcs/auto.log
exit 0
#给予脚本执行权限
sudo chmod +x /etc/rc.local
|