Everything you need to know about NVRAM

What is NVRAM ?

 

NVRAM is not popular to PC users but it is very familiar to Mac users. NVRAM is a type of RAM that retains data after the host device’s power is turned off. ( in contrast to RAM ). NVRAM is used to store values like: brightness, volume, computer name, Find My Mac’s ID, etc… In Windows and Linux these values aren’t stored in NVRAM but on the HDD, as most PCs don’t have NVRAM. OS X utilizes NVRAM to run many services like iMessage, FaceTime, boot device, etc…

 

NVRAM on PC

 

NVRAM, like UEFI, is implemented many new PC models, and many OSes like Windows and Linux start using it. For example, Windows in UEFI mode uses NVRAM to check if Secure Boot is enabled or not.

 

But everything does not work smoothly in the world of PC. In the beginning of the migration from Legacy BIOS to UEFI, many PCs are badly damaged due to unstable NVRAM. Notably many Samsung PCs got bricked due to bad NVRAM writing, in which CMOS reset is the only option to revive it or worse, it can sometimes corrupt firmware. Other OEMs starts to take things carefully and in new BIOS update, they can turn off NVRAM if any possible dangers is exposed.

 

How to test NVRAM ?

 

Open Terminal in OS X, type:

Then type this to show the current NVRAM:

You will see:

After rebooting, type nvram –p in Terminal and if you can still see the previous result then your NVRAM is working

 

NVRAM and Hackintosh

 

1/ Chameleon

 

Due to this bootloader’s limited implementation, Chameleon won’t keep all system’s efi-runtime before booting OS X, which means NVRAM won’t work even even if you already have native NVRAM enabled.

 

To solve the matter, the module “FileNVRAM” is created to emulate NVRAM for Chameleon. By integrating a NVRAM emulating module into OS X’s core, all features required working NVRAM will work normally. This module will loads the nvram file from disk early into memory so Filenvram has it before OS X is up and running, It also injects a kext in to OS X. The kext will handle the NVRAM API that OS X expects. This kext does legacy translation as well as writing the nvram to /Extra/nvramxxxxxxxx.plist when nvram is changed.

 

2/ Clover UEFI

 

Unlike Chameleon, Clover UEFI is more transparent for UEFI system, so it will use the system’s Native NVRAM (if exist).

 

To see if you have native NVRAM or not, go to /EFI/Clover/Drivers64UEFI/ and delete EmuVariableUEFI-64.efi, then restart. Follow the NVRAM testing procedure above, if it’s still working then you have native NVRAM support and you don’t need to use EmuVariableUEFI-64.efi; if not then put back EmuVariableUEFI-64.efi to use NVRAM.

 

EmuVariableUEFI-64.efi works by loading the newest nvram.plist from HFS+/FAT32 partitions and emulate NVRAM for OS X. But this driver CAN NOT save NVRAM  into the nvram.plist. Therefore, we need some solution to save nvram.plist at shutdown.

 

Install RC Script

 

You can install this by select “Install RC Script to target partition” in Clover <=2711

 

This is how Clover Installer saved NVRAM (up to Clover 2711).  It utilizes OS X’s feature of loading /etc/rc.local when booting up, and /etc/rc.shutdown.local when shutting down, Clover Installer added execute scripts to save log files into rc.local and save nvram.plist into rc.shutdown.local.

 

The truth is RC Script has been deprecated since the day of Leopard (10.5) but for some reasons it still survives till Mavericks (10.9). Unfortunately it is gone completely in Yosemite ( 10.10 ), so Clover users using RC Script in old installer now won’t be able to keep NVRAM after restarting, due to nvram.plist saving scripts won’t run at shutting down.

 

Use LoginHook/LogoutHook

 

To temporarily replace RC Scripts, some users use LoginHook/LogoutHook to replace rc.local/ rc.shutdown.local. LoginHook command will be run when logging in, and LogoutHook will run when logging out. This method still has some problems. The scripts will run only when login/logout, not starting/shutting down. This method is also deprecated since Tiger ( 10.4 ), so it will be a matter of time until it’s completely disappears.

 

Launchd

 

You can install this by select “Install RC Script to target partition” in Clover > 2711

 

This is the official method that Apple recommends to run scripts when starting/shutting down, and Clover revisions since 2712 has implemented it for better OS X support.

We will be happy to hear your thoughts

Leave a reply