ubuntu 20.04 sysctl 文件不能正常加载

今天发现一个问题, 升级到ubuntu20.04之后, 原本启动系统的时候,能正常加载sysctl.conf文件, 现在不能正常加载了。然后我就找到一个办法。

 

新建一个sysctlp.service文件, 位于/etc/systemd/system/这个目录下面

[Unit]
Description=Apply Kernel Variables
After=systemd-modules-load.service
[Install]
WantedBy=multi-user.target


[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/sysctl -p
TimeoutSec=90s

然后执行

systemctl enable sysctlp
systemctl start sysctlp
systemctl status sysctlp

就可以了

 

你应该可以看到类似的输出

● sysctlp.service - Apply Kernel Variables
     Loaded: loaded (/etc/systemd/system/sysctlp.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2020-05-01 03:52:20 UTC; 20min ago
    Process: 646 ExecStart=/sbin/sysctl -p (code=exited, status=0/SUCCESS)
   Main PID: 646 (code=exited, status=0/SUCCESS)

May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.ipv6.conf.default.disable_ipv6 = 1
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.ipv6.conf.lo.disable_ipv6 = 1
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.ipv6.conf.eth0.disable_ipv6 = 1
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.core.default_qdisc = cake
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.ipv4.tcp_congestion_control = bbr
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: net.ipv4.tcp_notsent_lowat = 16384
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: vm.max_map_count = 65536
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: fs.inotify.max_user_watches = 65536
May 01 03:52:20 ip-172-26-2-154 sysctl[646]: fs.file-max = 65536
May 01 03:52:20 ip-172-26-2-154 systemd[1]: Finished Apply Kernel Variables.

发布于: 2020-05-01 12:13:09, 点击数:

Tumblr
Pinterest
LinkedIn
Reddit
XING
WhatsApp
Hacker News
VK
Telegram