Skip to content

Instantly share code, notes, and snippets.

@cetinajero
Last active May 15, 2024 21:48
Show Gist options
  • Save cetinajero/ec9fa1d52773c7dcb545e11991f5d17a to your computer and use it in GitHub Desktop.
Save cetinajero/ec9fa1d52773c7dcb545e11991f5d17a 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
diskutil unmountDisk /dev/disk2
sudo gdd if=ubuntu-20.04-desktop-amd64.iso of=/dev/rdisk2 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

Define constants

DEVICE_ID="/dev/disk2"
PART_NAME="W10_2111X64"
ISO_NAME=Win10_21H2_Spanish\(Mexico\)_x64.iso 

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 $DEVICE_ID 2 MBR FAT32 $PART_NAME $((558 * 100 / 775 + 1))% EXFAT Archivos R

Set the partition as active (boot flag)

(echo flag 1 ; echo write ; echo y ; echo exit) | sudo fdisk -e $DEVICE_ID ; 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 $DEVICE_ID
sudo dd if=syslinux-4.07/mbr/mbr.bin of=$DEVICE_ID 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 $(echo $DEVICE_ID)s1

Write the syslinux's modules (COM32 modules)

mkdir /Volumes/$PART_NAME/syslinux
cp syslinux-4.07/com32/chain/chain.c32 /Volumes/$PART_NAME/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/$PART_NAME/syslinux/syslinux.cfg

Mount the ISO

hdiutil mount ~/Downloads/$ISO_NAME -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/$PART_NAME/
# or
rsync -avh --progress --exclude=sources/install.wim /Volumes/ISO/ /Volumes/$PART_NAME/
# or
cp -Rpv /Volumes/ISO/ /Volumes/$PART_NAME/

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

brew install wimlib
wimlib-imagex split /Volumes/ISO/sources/install.wim /Volumes/$PART_NAME/sources/install.swm 3800

Unmount the USB

diskutil unmountDisk $DEVICE_ID
# or 
hdiutil unmount /Volumes/$PART_NAME/

Configure Windows Installer to always ask for the version to install

echo -e "[Channel]\nRetail" > /Volumes/$PART_NAME/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

Install Windows 11 without Internet

  1. Open Task Manager
  • Shift + F10
  • Run taskmgr
  1. End the Network Connection Flow (i.e. Flujo de conexión de red) task several times.

Get the Windows activations status

Use the Server License Manager tool

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