Skip to content

Instantly share code, notes, and snippets.

@papapana
Forked from cetinajero/macos_boot_keys.md
Created October 30, 2021 21:25
Show Gist options
  • Save papapana/e519c0c25719a7b851c9dda454eaf54f to your computer and use it in GitHub Desktop.
Save papapana/e519c0c25719a7b851c9dda454eaf54f to your computer and use it in GitHub Desktop.
macOS Boot combination keys and bootable USB commands

macOS Boot combination keys

Keys Description
Startup Manager
Safe mode
D Apple Diagnostics
+ D Apple Diagnostics over Internet
+ V Verbose mode
+ S ó + R Single-user mode
+ R Install the latest macOS that was installed on your Mac
+ + R Upgrade to the latest macOS compatible with your Mac
+ + + R Install the original macOS, or closest still available
+ + P + R Reset NVRAM or PRAM
T Target Disk

Reset a macOS user password

Open the Terminal.app from within macOS Recovery ( + R) and type:

resetpassword

Burn a CD/DVD from an ISO9660 ISO file

hdiutil burn image.iso

Burn a USB from an ISOHybrid ISO file

An ISO with a DOS/MBR boot sector is required.

file ubuntu-20.04-desktop-amd64.iso
sudo gdd if=ubuntu-20.04-desktop-amd64.iso of=/dev/disk2 bs=4096 status=progress
sudo cmp /dev/disk2 ubuntu-20.04-desktop-amd64.iso

Create a UEFI bootable USB from an ISO file

The /efi/boot/bootx64.efi bootloader is required.

diskutil list
diskutil partitionDisk /dev/disk2 1 MBR FAT32 W10_1909SPA R
hdiutil mount ~/Downloads/Win10_1909_Spanish\(Mexico\)_x64.iso -mountpoint /Volumes/ISO
rsync -avh --info=progress2 /Volumes/ISO/ /Volumes/W10_1909SPA/
diskutil unmountDisk /dev/disk2

Create a MBR bootable USB from an ISO file

Format the USB

diskutil list

# diskutil partitionDisk MountPoint [numberOfPartitions] [APM|MBR|GPT] [part1Format[FAT32|ExFAT|JHFS+|APFS|...] part1Name part1Size[%|R] part2Format part2Name part2Size part3Format part3Name part3Size ...]
diskutil partitionDisk /dev/disk2 1 MBR FAT32 W10_2004X64 R

Set the partition as active (boot flag)

(echo flag 1 ; echo write ; echo y ; echo exit) | sudo fdisk -e /dev/disk2 ; echo

Write the syslinux's MBR (Master Boot Record)

curl https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.07.tar.gz -o syslinux-4.07.tar.gz
tar -zxvf syslinux-4.07.tar.gz
diskutil unmountDisk /dev/disk2
sudo dd if=syslinux-4.07/mbr/mbr.bin of=/dev/disk2 bs=440 count=1

Write the syslinux's VBR (Volume Boot Record)

curl https://raw.githubusercontent.com/unetbootin/unetbootin/master/src/unetbootin/unetbootin.app/Contents/Resources/syslinux-mac -o syslinux-mac
chmod +x syslinux-mac
sudo ./syslinux-mac -i /dev/disk2s1

Write the syslinux's modules (COM32 modules)

mkdir /Volumes/W10_2004X64/syslinux
cp syslinux-4.07/com32/chain/chain.c32 /Volumes/W10_2004X64/syslinux

Write the syslinux's config (syslinux.cfg)

echo -e "DEFAULT boot\n\nLABEL boot\n\tMENU LABEL boot\n\tCOM32 chain.c32\n\tAPPEND fs ntldr=/bootmgr" > /Volumes/W10_2004X64/syslinux/syslinux.cfg

Mount the ISO

hdiutil mount ~/Downloads/Win10_2004_Spanish\(Mexico\)_x64.iso -mountpoint /Volumes/ISO

Validate if the install.wim file is greater than 4GiB minus 1 byte

if (( `wc -c</Volumes/ISO/sources/install.wim` > 2**32-1 )) ; then echo Exceeds ; fi

Copy the small ISO files to the USB

rsync -avh --info=progress2 --exclude=sources/install.wim /Volumes/ISO/ /Volumes/W10_2004X64/
# or
rsync -avh --progress --exclude=sources/install.wim /Volumes/ISO/ /Volumes/W10_2004X64/
# or
cp -Rpv /Volumes/ISO/ /Volumes/W10_2004X64/

Copy the install.wim file to the USB in smaller parts

wimlib-imagex split /Volumes/ISO/sources/install.wim /Volumes/W10_2004X64/sources/install.swm 3800

Unmount the USB

diskutil unmountDisk /dev/disk2
# or 
hdiutil unmount /Volumes/W10_2004X64/

Configure Windows Installer to always ask for the version to install

echo -e "[Channel]\nRetail" > /Volumes/WIN10HSL/sources/ei.cfg

Get the Windows activation key from the BIOS

Windows: wmic path softwarelicensingservice get OA3xOriginalProductKey

GNU Linux: sudo hd /sys/firmware/acpi/tables/MSDM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment