Skip to content

Instantly share code, notes, and snippets.

@i8degrees
Last active October 15, 2025 14:21
Show Gist options
  • Save i8degrees/901676ee5a4d4a772758f70575306ccc to your computer and use it in GitHub Desktop.
Save i8degrees/901676ee5a4d4a772758f70575306ccc to your computer and use it in GitHub Desktop.
shutdown workaround patch
# Remark1: see https://uefi.org/sites/default/files/resources/UEFI_Shell_2_2.pdf for information
# Remark2: for manual shutdown or using EFI shell
# - SHUTDOWNSCRIPT is not required
# - remove "-u -@ ./cmdline.bin"
# - the command from "cd ..." to "iconv ..." is not required
# Path to device file to disk contains selected EFI partition
DISKFILE=/dev/nvme0n1
# selected EFI partition, index start at 1
PARTNUM=1
# entry number do you want to create entry, recommened to be the equals to highest entry number visibled in the command `efibootmgr` added 1.
ENTRYNUM=0006
# Path to EFI Shell executable file relative to selected EFI partition, using backslash
EFIFILE='\EFI\EFI_Shell\Shell.efi'
# Path to auto-shutdown script relative to selected EFI partition, using backslash
SHUTDOWNSCRIPT='\EFI\EFI_Shell\Scripts\shutdown.nsh'
# Name of EFI entry
ENTRYNAME="Auto Shutdown workaround for Surface+Linux"
cd `mktemp -d`
echo -n "-nostartup -noconsoleout -noconsolein -nointerrupt -nomap -noversion $SHUTDOWNSCRIPT" > ./cmdline.text
iconv -f ascii -t ucs-2 ./cmdline.text > ./cmdline.bin
efibootmgr -v -b $ENTRYNUM -c -d $DISKFILE -l "$EFIFILE" -p $PARTNUM -L "$ENTRYNAME" -u -@ ./cmdline.bin
# for disabling the entry so we dont have to worry about entry sorting
efibootmgr -b $ENTRYNUM -A
# /EFI/EFI_Shell/Scripts/shutdown.nsh
# [SOURCE](https://github.com/linux-surface/linux-surface/wiki/Intel-12th-Generation-Devices-Issues#power-stateoperation-workaround-via-efi-shell)
@reset -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment