如果 Mac 无法完成启动,请尝试安全模式
如果 Mac 无法开机应如何处理
/System/Library/StartupItems/
DEPRECATED AND REMOVED FUNCTIONALITY
launchctl no longer has an interactive mode, nor does it accept commands from stdin.
The /etc/launchd.conf file is no longer consulted for subcommands to run during early
boot time; this functionality was removed for security considerations. While it was
documented that $HOME/.launchd.conf would be consulted prior to setting up a user's
session, this functionality was never implemented.
launchd no longer uses Unix domain sockets for communication, so the LAUNCHD_SOCKET
environment variable is no longer relevant and is not set.
launchd no longer loads configuration files from the network
FILES
~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System wide daemons provided by the administrator.
/System/Library/LaunchAgents OS X Per-user agents.
/System/Library/LaunchDaemons OS X System wide daemons.
插曲--Mac Pro无法启动
本来想禁止apache开机自启动
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
结果太大意,没想到手快了一步,命令敲成了
launchctl unload -w /System/Library/LaunchDaemons/
我的个乖乖,突然触摸板,键盘全部失灵,有点慌了,怎么回事儿,还好有点linux基础,看了下命令,把系统的很多Daemons直接停掉并去除了开机启动了,重启后直接卡死在苹果LOGO下,进度好容易走完了,却看不能美美的桌面,完了。真的是没法加载相关Daemon从而加载硬件驱动,系统无法正常启动。
问了下度娘,有说重新加载SMC的,详风苹果官方文档https://support.apple.com/zh-cn/HT201295
试了下,没效果不说,反而风扇狂转不止,更加担心了,难道要重装,oh, my god
又百度了下,看了下无法启动的基本排查思路和顺序,理了理头绪,既然是不小心去掉了开机启动项,还原回去就可以了,于是
A方案(失败)
进Recovery模式,将unload掉的全部加入到开机启动项后重启
chroot /Volumes/Macintosh HD
cp -a System/Library/LaunchDaemons/* Library/StartupItems/
Note that allowing non-root write access to the
/System/Library/LaunchDaemons directory WILL render your system unbootable.
-w Overrides the Disabled key and sets it to false or true for the
load and unload subcommands respectively. In previous versions,
this option would modify the configuration file. Now the state of
the Disabled key is stored elsewhere on- disk in a location that
may not be directly manipulated by any process other than launchd.
jlive@MacBook-Pro:~ $su -
Password:
MacBook-Pro:~ root# ls /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 87 1 0 11:18PM ?? 0:01.56 /usr/sbin/httpd -D FOREGROUND
70 246 87 0 11:18PM ?? 0:00.03 /usr/sbin/httpd -D FOREGROUND
0 3971 3964 0 3:20PM ttys000 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl stop org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 3988 3964 0 3:20PM ttys000 0:00.00 grep httpd
2.daemon start
MacBook-Pro:~ root# launchctl start org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4000 1 0 3:23PM ?? 0:00.15 /usr/sbin/httpd -D FOREGROUND
70 4001 4000 0 3:23PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
3.daemon list
MacBook-Pro:~ root# launchctl list|grep apache
4035 0 org.apache.httpd
0 4003 3964 0 3:23PM ttys000 0:00.00 grep httpd
说明:load|unload并不一定会start|stop相关服务,它只是在start或stop前载入相关配置环境
4.unload plist
MacBook-Pro:~ root# launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4237 4221 0 4:01PM ttys001 0:00.00 grep httpd
4.load plist
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4241 1 0 4:01PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4243 4241 0 4:01PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4245 4221 0 4:01PM ttys001 0:00.00 grep httpd
5.print service-target
MacBook-Pro:~ root# launchctl print system/org.apache.httpd|head
org.apache.httpd = {
active count = 1
path = /System/Library/LaunchDaemons/org.apache.httpd.plist
state = running
program = /usr/sbin/httpd-wrapper
arguments = {
/usr/sbin/httpd-wrapper
-D
FOREGROUND
6.kill service-target
MacBook-Pro:~ root# ps -ef|grep httpd
0 4417 1 0 4:21PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4423 4417 0 4:21PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4429 4221 0 4:21PM ttys001 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl kill SIGKILL system/org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4431 1 0 4:21PM ?? 0:00.15 /usr/sbin/httpd -D FOREGROUND
70 4432 4431 0 4:21PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4434 4221 0 4:21PM ttys001 0:00.00 grep httpd
7.disable service-target
MacBook-Pro:~ root# launchctl disable system/org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4451 4221 0 4:24PM ttys001 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist: Service is disabled
8.enable service-target
MacBook-Pro:~ root# launchctl enable system/org.apache.httpd
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4458 1 0 4:25PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4459 4458 0 4:25PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4461 4221 0 4:25PM ttys001 0:00.00 grep httpd