netplan apply
当我以 root 用户身份执行该命令时,该命令返回一些错误。
root@szyf1272:/etc/netplan# netplan apply
System has not been booted with systemd as init system (PID 1). Can't operate.
System has not been booted with systemd as init system (PID 1). Can't operate.
Traceback (most recent call last):
File "/usr/sbin/netplan", line 23, in <module>
netplan.main()
File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 186, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 46, in run
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 186, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/apply.py", line 116, in command_apply
utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services)
File "/usr/share/netplan/netplan/cli/utils.py", line 86, in systemctl_networkd
subprocess.check_call(command)
File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'stop', '--no-block', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.
答案1
systemd 响应以下命令返回此错误:
systemctl stop --no-block systemd-networkd.service 'netplan-wpa-*.service'
这将检查是否/run/systemd/system
存在并且可以访问。
在正确启动的 Ubuntu 20.04 系统上,这始终是正确的。
我不知道您做了什么导致该目录不存在,但是这样的系统已经严重损坏且无法支持。