2011款MacBook Pro Ubuntu Live DVD模式下写入efivars失败求助
Let's break down why you're hitting this error and how to fix it—this is a common gotcha with EFI variables on older MacBooks.
The Root Cause
When writing to EFI variables via /sys/firmware/efi/efivars, each file requires a 4-byte attribute header before the actual value you want to set. Your current command only writes the 4-byte value (\x01\x00\x00\x00) which overwrites the required attribute data, leading the system to reject the write with "Invalid argument".
Step-by-Step Solution
Ensure you're running as root
In the Ubuntu Live DVD environment, you’ll need elevated privileges. Either prefix commands withsudoor switch to root with:sudo -iWrite the variable with the correct attribute header
Thegpu-power-prefsvariable needs the standard EFI variable attributes (non-volatile, boot service access, runtime access) encoded as\x07\x00\x00\x00(little-endian for 0x07). Append your desired value to this header:printf "\x07\x00\x00\x00\x01\x00\x00\x00" > /sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9Verify the variable was set correctly
Check the contents to confirm:hexdump -C /sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9You should see output starting with
00000000 07 00 00 00 01 00 00 00—the first four bytes are the attributes, the next four are your preference to use the integrated GPU.
If the Variable Already Exists
If the gpu-power-prefs file already exists, you can first read its existing attributes to avoid overwriting them incorrectly:
# Read the first 4 bytes of the existing variable head -c 4 /sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9 > attr.bin # Append your desired value and write back cat attr.bin <(printf "\x01\x00\x00\x00") > /sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9 rm attr.bin
Additional Notes for 2011 MacBook Pro
Even after setting this variable, you might need to add kernel parameters to fully disable the discrete GPU during boot:
- When booting from the Live DVD, press
ein GRUB to edit the boot entry - Add
nouveau.blacklist=1 acpi_osi=Darwinto the end of the line starting withlinux - Press
Ctrl+Xto boot with these parameters
This helps avoid conflicts between the NVIDIA nouveau driver and the integrated Intel GPU.
内容的提问来源于stack exchange,提问作者Wes Sayeed

