Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My iMac AHT Project Documentation #21

Open
marcushh777 opened this issue Feb 11, 2016 · 3 comments
Open

My iMac AHT Project Documentation #21

marcushh777 opened this issue Feb 11, 2016 · 3 comments

Comments

@marcushh777
Copy link

iMac AHT Diagnostics Restoration Project Documentation
by Mark H. Harris February 2016

This page documents the AHT .diagnostics restoration project following the El Capitan upgrade on my mid 2009 iMac9,1 board F2218EA9, following a memory upgrade from 2 Gb to 8 Gb.

The El Capitan upgrade blew away the .diagnostics folder from /System/Library/CoreServices/ so that the diagnostic booting (while holding down the D key after the chimes) no longer works— so that I was not able to check out the 8 Gb memory expansion. Because I purchased my iMac second hand without the original boot key nor installation disks I was unable to run memory diagnostics; a common problem these days.

I was able to successfully restore the .diagnostics folder from a .dmg image which I obtained from Github; the explanation and documentation of which is following:

First, I obtained the primary instructions, and the .dmg image file, from Github at the following link:

https://github.com/upekkha/AppleHardwareTest

I found the link to be complete (for the most part), and very helpful. I especially appreciate the work of making the various .dmg links available for download; very nice. The reason for documenting my project procedures is to note some clarifications, with helpful tips and techniques, for assisting those who have older iMacs (mine is mid 2009) and who also have chosen to upgrade to El Capitan (which has SIP enabled by default). I was able to get the restored on-board .diagnostics to boot (while holding down the D key) by essentially restoring the .diagnostics folder for my board (F2218EA9) to /System/Library/CoreServices/ (obtained from Github) and then proceeding with the D key boot-up.

iMac Board Number

The first step is to determine the iMac board number. The technique used (terminal commands) for determining the model and number are correct from the instructions. I placed the following commands in a script file which I called board_test:

———————————— begin —————————————

echo "---------------- Board Identifier"

sysctl hw.model | awk '{ print $2 }'
ioreg -l | awk -F" '/board-id/ { print $4 }'

———————————— end —————————————

I found that I have an iMac9,1 F2218EA9. It is important to download the .dmg file that matches the correct board. The numbers are cross-referenced on the Github site. I downloaded the corresponding file (022-4297-A.dmg) that matches my board F2218EA9 (the link is printed below) by clicking the link provided on Github:

(download.info.apple.com/Apple_Hardware_Test/022-4297-A.dmg)

Mount the Disk Image

The second step(s) is to mount the dmg disk image, copy the image to a backup directory and correctly set the permissions (this is important).

Once downloaded, the disk image .dmg file is placed on the Desktop and is mounted by clicking the icon (I created an archive folder on the desktop to hold the .dmg file, as well the archive backup .diagnostics folder I made later).

The .diagnostics folder mounted at the following path when the icon was clicked:

/Volumes/AHTEOne/System/Library/CoreServices/.diagnostics/

I backed up the .diagnostics folder to my /Users/user/Desktop/archive/ folder in preparation for setting the permissions with the following command(s) below; tar is better than cp or mv because it reliably maintains the permissions as it recursively copies… a nice trick for other things too! It works by archiving (and unarchiving) via standard in|out. I used a terminal to enter the following command(s):

cd /Users/user/Desktop/archive/

sudo tar -cvf - -C /Volumes/AHTEOne/System/Library/CoreServices .diagnostics | sudo tar -xvf -

sudo chown -R root .diagnostics

sudo chgrp -R wheel .diagnostics

The final two commands above set the permissions for the entire .diagnostics archive directory recursively… these permissions will be preserved later when we use the tar command again to move the backup into the real /System/Library/CoreServices/ folder.

Disable System Integrity Protection (SIP)

This step is important for El Capitan to be able to write to the /System folder. I booted the iMac with the [command] - R key held down after the chimes to pull up the recovery options menu. I used the utilities folder (of the recovery options menu) to start a terminal and enter the following command:

csrutil disable; reboot

After the iMac boots up verify the status of SIP from a terminal with:

csrutil status

SIP can be enabled again later (recommended) when all is finished with the reversing command (again from recovery—>utilities—>terminal):

csrutil enable; reboot

Copy Diagnostics archive to the /System

I used a terminal to enter the following command(s):

cd /System/Library/CoreServices/

sudo tar -cvf - -C /Users/user/Desktop/archive .diagnostics | sudo tar -xvf -

The above commands will copy the archived .diagnostics folder into the proper path while maintaining the permissions throughout the directory structure.

The .diagnostics directory for my iMac9,1 board F2218EA9 was successfully restored.

Boot into the Diagnostics AHT

I successfully booted into the AHT by holding down the D key after the chimes and waiting for the AHT icon and menu to follow. It is important to make sure the utility probes the hardware completely before attempting to run TEST, or to look at the hardware report.

My AHT came up as version 3.3.1 - 3A168 C2000-2009 and correctly identified the installed hardware including the new 8 Gb memory. All TEST ran normally… yessss

@marcushh777 marcushh777 changed the title iMac AHT Project Documentation My iMac AHT Project Documentation Feb 11, 2016
@marcushh777
Copy link
Author

I was also able to make a boot-key; which is very handy-- no keys held down, just boots directly into AHT with the boot-key installed.

The difficulty for El Capitan users is that the 'bless' command (see previous instructions for making a boot-key; see note* below) fails on Capitan if SIP is enabled. Once the boot-key is blessed properly SIP may be re-enabled and the boot-key will still boot directly into AHT.

An additional note if using a boot-key: when finished on the AHT menu use the 'shutdown' option rather than the 'restart' option otherwise the system will boot into AHT again... after the machine is shutdown then yank the boot-key.

Also, the boot-key does not have to be dedicated to the AHT boot process... it can be used to hold other archives, etc. It does NOT have to be formatted; a standard boot-key out-of-box works nicely.

note* I used 'bless' with mount mode and --setboot; this requires SIP to be disabled for the blessing.

cd /Volumes/usbstick
sudo bless --mount /Volumes/usbstick --setboot --file diags.efi
sudo reboot

@imapp9
Copy link

imapp9 commented Nov 18, 2016

I did "sudo tar -cvf - -C /Volumes/AHTEOne/System/Library/CoreServices .diagnostics | sudo tar -xvf -". it asked for a password. Why is that when my login is admin and no password?

@FTT2004
Copy link

FTT2004 commented Jan 28, 2021

Hi. I realise this is resurrecting an old thread, but I am encountering the following issue when following your instructions. SIP was disabled.

sudo tar -cvf - -C /Volumes/AHTEOne/System/Library/CoreServices .diagnostics | sudo tar -xvf - resulted in the following error:
tar: could not chdir to '/Volumes/AHTEOne/System/Library/CoreServices'

Looking this up hasn't revealed anything conclusive.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants