Skip to main content

Virtualization - macOS VirtualBox guest hardware identification

For macOS 11.x (Big Sur)

#!/bin/bash

# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/

# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01

# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)

sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M

GetVMDetails() {
  sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')" 
  sBP="$(echo "${sKey}" | grep DmiBoardProduct  | sed 's/^.*Value: //')"
  sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
  sSS="$(echo "${sKey}" | grep DmiSystemSerial  | sed 's/^.*Value: //')"
}

if [[ "$(uname -r)" == *Microsoft ]]; then
  VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
  VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
  VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
  VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit

sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"

nSeq=0

"${VB}" list -s vms | grep "Mac OS X 11." | cut -d\" -f2 | sort | while read sVMName; do

  echo "${sVMName}"
  GetVMDetails
  printf '   Current => %-35s : %-25s : %s : %s\n'  "${sVMName}" "${sBP}" "${sSP}" "${sSS}"

  nSeq=$((nSeq + 1))

  # iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
  # MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
  sSequantial="1Q${sValidDigit:${nSeq}:1}"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct"  "${sBoardId}"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial"  "C02XH${sSequantial}${sProductCode}"

  # C02 -> Factory/Line number
  # XH  -> 2018/October

  GetVMDetails
  printf '   New     => %-35s : %-25s : %s : %s\n'  "${sVMName}" "${sBP}" "${sSP}" "${sSS}"


done

For macOS 12 (Monterey)

#!/bin/bash

# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/

# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01

# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)

sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M

GetVMDetails() {
  sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')" 
  sBP="$(echo "${sKey}" | grep DmiBoardProduct  | sed 's/^.*Value: //')"
  sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
  sSS="$(echo "${sKey}" | grep DmiSystemSerial  | sed 's/^.*Value: //')"
}

if [[ "$(uname -r)" == *Microsoft ]]; then
  VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
  VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
  VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
  VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit

sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"

nSeq=0

"${VB}" list -s vms | grep "Mac OS X 12." | cut -d\" -f2 | sort | while read sVMName; do

  echo "${sVMName}"
  GetVMDetails
  printf '   Current => %-35s : %-25s : %s : %s\n'  "${sVMName}" "${sBP}" "${sSP}" "${sSS}"

  nSeq=$((nSeq + 1))

  # iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
  # MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
  sSequantial="1Q${sValidDigit:${nSeq}:1}"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct"  "${sBoardId}"
  "${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial"  "C02XH${sSequantial}${sProductCode}"

  # C02 -> Factory/Line number
  # XH  -> 2018/October

  GetVMDetails
  printf '   New     => %-35s : %-25s : %s : %s\n'  "${sVMName}" "${sBP}" "${sSP}" "${sSS}"


done

Comments

Popular posts from this blog

Movies - Deadpool & Wolverine (2024)

 

TV Mini-serie - Lady in the Lake (2024)

 

Movie - The Gorge (2025)

  My views For 80 years everything was ok ... until they sent a woman For sure is DTV ... really bad Inside the gorge is clearly designed and written by a gamer Plot Two elite  snipers  receive identical missions: travel to an undisclosed location and guard the West and East sides of a deep gorge for one year without any contact with the outside world nor their counterpart on the opposite side. Levi Kane, a former  U.S. Marine  and current  private contractor  accepts the offer to guard the West tower. Drasa, a  Lithuanian  covert operative frequently employed by the  Kremlin , agrees to guard the East side. Upon arriving, Levi relieves his predecessor, J.D., a  British   Royal Marine  of duty and asks for specifics about the mission. J.D. explains that in addition to the towers on the East and West, there are automated turret defenses to the North and South, a powerful signal ‘ cloak ,’ and  explosives on the walls ...