1. in Terminal: sudo nano /etc/save.nvram
Create an empty save.nvram file in the /etc folder.
在终端中输入sudo nano /etc/save.nvram,创建一个空的文件save.nvram在/ect下面
2. in Nano editor I filled the save.nvram file with these commands:
在Nano编辑器中输入下面的命令
#!/bin/bash
nvram -x -p > "/nvram.plist"
if [[ -f "/nvram.plist" ]]; then
chflags hidden "/nvram.plist"
fi
复制代码
This is the save.nvram file content. It's just make an nvram.plist file in the root of the OS partition and makes the file hidden.
5. in Terminal: sudo defaults write com.apple.loginwindow LogoutHook /etc/save.nvram
This writes the newly created command file into loginwindow's LogoutHook. This means our script will run on each logout. So the nvram getting saved on each logout,restart,and shutdown.