165 points · by giuliomagnifico · 5y ago · 147 comments
This isn't new with the M1 Macs. This has been a thing since they introduced APFS. When they went into disk utility after the cli - Then they could delete everything and kick off the OSX Install.
If the APFS Volume Group still exists the installer will try to unencrypt and work with it. So.. In short, just make sure you delete the volume group. There's a specific button for it. I just did this yesterday on a T2 Mac.
Why does the recovery not just have a button called factory reset which unlinks your apple account, deletes the volume and then sets it all up like new.
It's important to note that most people are incredibly gullible when it comes to technology, and they won't hesitate to buy a second-hand iPhone (whether stolen or not) for a few bucks assuming they'll be able to use it, because that's what a phone does, only to find themselves trapped in iCloud lock.
Locking devices does not protect users (contrary to encrypting the local storage), and does not deter anyone from stealing. It simply adds one layer of mafia to deal with (iCloud unlock shady companies) when you're just trying to find a second-hand phone.
Boot into recovery, when it asks for a password say youve forgotten it, you don't have a key, and click the resulting "Erase Mac" button. This will erase the drive properly removing the partitions, iirc.
I'll grant that this is poorly documented and not intuitive in the least. A secure erase and reinstall is a common task. It shouldn't require an obscure menu bar option or the use of Terminal.
If you have nvme storage use blkdiscard to wipe it:
https://man7.org/linux/man-pages/man8/blkdiscard.8.html
Or
nvme format <device> with the --ses option, see available ses options here:
https://www.mankier.com/1/nvme-format
Otherwise use ATA Secure Erase with the suspend trick to unfreeze the drive:
Suspending and waking a PC to unlock a drive can be necessary for SATA or NVMe drives. SATA drives also give you the alternative of hot-swapping the drive, but that's not practical for consumer NVMe drives or consumer host systems.
https://support.apple.com/en-us/HT201065
I've found the process is fast if you have a good internet connection to download macOS again. Otherwise, that's where it seems a lot of the time goes.
https://support.apple.com/en-us/HT201065
To be honest I’m not 100% sure if the ‘sign out of iCloud’ also removes activation lock, but I do think so. They also refer to the steps in the Activation Lock article:
I’m not sure if it’s fixed now, but I don’t think it was related to the volume group.
Similarly you can get your disks in a state where the Windows installer can’t make heads or tails of it, so you need to just write zeros over the boot sector before Windows can install.
Even spend hours with apple support and nothing worked, there is more to it than just that.
State is evil!
> There's a specific button for it.
Does the button say "hi, you should pick this unless you're an expert with a really good reason not to?"
It should not be possible to brick a device by pushing the wrong button. I was shocked that this wasn't caught by anyone at Apple before release.
So you think all Apple devices should be shipped without root? Or that anything disk-related should only be allowed through CLI as root?
I thought any problem encountered reinstalling an OS is something I could handle. But that was not the case. Near as I could tell when I followed up with Apple after the incident, the boot process involved the security chip reading some data off the drive and validating it before handing off control. If that data (which is on the Apple reserved partition) was wiped, the firmware would not boot. And since the security chip was configured to not boot from media (the default state, IIRC), it was effectively bricked.
So the very first generation of TouchBar MacBooks would not boot into recovery mode if you wipe the drive, nor would they boot any kind of recovery media. It's a state that required shipping to Apple for refurbishment to fix. It's my understanding that this was fixed in later models, perhaps even as a result of my incident.
Recovery know I have OS installed, but because it's not installed the same way it no longer able to find credentials for authentification. And yeah I don't have second Macbook to properly factory reset it.
Along the way I stuck into 3 huge bugs and experience was terrible. Fortunatelly Apple support page actually show how to bypass it's bugs with command line magic which is easy for me as Linux nerd.
https://support.apple.com/en-us/HT211983
You even have to go through "Erase Mac" twice in process. It's only work if you reboot it properly after each time which is not mentioned on support page. Such a mess.
I remember a poster on HN saying that after some exploit for the T2 security chip came out, they were making money from being paid by thieves to use the exploit to wipe the devices.
Of course they said they don't ask any questions which as we all know is an iron clad defence lol
IIRC iPods were similar. Early on, people wearing white headphones were targeted by thieves.
https://twitter.com/braincode/status/1360117171842478081
Device enrollment prompts are indeed annoying :/
Instead with ARM you can’t mount the disk as an external drive. That’s why this mess started!
Here is what you need to know to actually understand these things:
The SSD has 3 partitions. Each partition is an APFS container. Each container contains multiple APFS volumes.
Your OS, and everything you care about, is on the second partition/container.
The first partition contains boot configurations. The third partition contains the One True Recovery OS (1TR), which includes the Boot Picker menu (that thing you get when you hold down the power button). These partitions form part of system firmware, think of them as part of UEFI/BIOS. Do not touch these. If you mess up those volumes, the only way to recover the machine is via Apple Configurator 2 from another Mac (DFU mode).
Disk Utility, the GUI, is broken sometimes. If something doesn't work properly there, ditch it and use the command line.
Both Disk Utility, the GUI, and diskutil, the CLI, will hide the first and last APFS containers from you to stop you from shooting yourself in the foot. They're still there, just hidden from the main listing. You can get info for them. Be careful with that.
To do OS reinstalls, you want to be in 1TR. This is not the macOS recovery. Hold down the power button and pick Startup Options from there. Then you can use diskutil (preferably the command line version). You should delete the whole APFS container (disk0s2 usually) corresponding to your install, which will contain multiple volumes. Re-create it as APFS. That will create a container with one volume. You can then install to it and the macOS installer will create all the other volumes.
Additionally, the SEP data is stored separately from the OS (in one of the volumes of the first container). To wipe that, after wiping the partition and before reinstalling, run `xartutil --erase-all`. I've never tried that myself, and I suspect it's not really required because a reinstall should start with a fresh store, but it's probably a good idea to try if you have authentication/user-related issues after reinstalling.
There is also OS recovery, which is the recovery instance that comes with an OS install. It looks exactly the same as 1TR, but it's not the same, and this is highly confusing. For any serious digging around, you want to be in 1TR. Booting holding down the power button will get you there, usually; after a failed macOS boot I've seen it go into regular recovery anyway. To be absolutely sure, boot into 1TR (holding down power, then startup options), then do a clean shutdown, and boot again the same way.
More info on what's on the SSD of these things:
I believe the "Erase Mac" function in Recovery Assistant also erases the SEP data, based on the output of `xartutil --list` before and after. If I'm correct about that, going through Recovery Assistant should be the recommended way to fully erase an M1 Mac (short of a DFU restore through Apple Configurator which also restores firmware).
On T2 Macs, `xartutil --erase-all` would wipe all SEP data, including the encryption keys used for the drive. In other words, it was the equivalent of a secure erase and was my recommended way to fully erase a Mac before resale. I suspect Recovery Assistant is just doing the equivalent of `xartutil --erase-all`, but I haven't tried `xartutil --erase-all` on an M1 because I'm afraid to brick the machine to the point of needing a DFU restore, and I don't have another Mac at hand to run Apple Configurator with right now.
I think the best bet, security-wise, if you really want to do a full/complete/total OS format/reinstall, is to boot external media, force zeroize all of disk0 (including 1TR), and use DFU mode to restore the .ipsw using Apple Configurator.
This is, of course, way more of a pain in the ass, and requires another computer, and internet access, but hopefully has the added benefit of leaving very little (really, the smallest amount practically possible without disassembly/extreme measures) persistent state on the machine from before the reinstall.
> Boot environment requirements: software-launched macOS Recovery or 1TR.
The only way I know of to get to any recovery mode is by holding down the power button, which the man page says is 1TR (though I know you mention seeing that boot into regular recovery anyway).
It also answers my question about the distinction between OS recovery and 1TR:
> Note: Apple uses the term One True recoveryOS (1TR) to indicate a boot into the primary recoveryOS which is achieved using a physical power button press. This is different from a normal recoveryOS boot, which can be achieved using NVRAM or which may happen when errors occur on startup. The physical button press increases trust that the boot environment isn’t reachable by a software-only attacker who has broken into macOS.
[1] https://manuals.info.apple.com/MANUALS/1000/MA1902/en_US/app...
* boot external USB installer media
* run `diskutil zeroDisk force /dev/disk0`
* run `nvram -c`
* power system off
* system will now fail to boot anything, including external media, because it has no firmware available
* put system in DFU mode [1]
* plug in USB-C cable to the correct port (only one usb-c port can be used for this purpose) and connect to another mac running Apple Configurator 2 (which, sadly, is only available via the App Store, so requires an Apple ID, and also requires internet access to activate the attached M1 device)
* Restore IPSW such as [2] (note that this is for 11.2.0 and is no longer current as of a week or two ago)
This is the best way to get an M1 back into as close to a "factory" state as possible. Unfortunately, it requires an Apple ID (to use the App Store), so you have to dox yourself to Apple (email and working phone number, at the minimum) to get the Apple Configurator 2 app. (If anyone knows how to copy an App Store app from one mac to another, freshly installed mac, and have it work without logging in, please email me.)
PS: If you're looking to go even deeper, following the zeroDisk you might wish to create a 100% blank/empty hfs volume on the disk0, and then "repair" it, which will TRIM the free space (99%+ of the disk) at the disk controller level as well. This may or may not have the same effect as writing all zeroes. You'll likely have to use `diskutil` to do this, as Disk Utility is mostly garbage.
[1]: https://support.apple.com/guide/apple-configurator-2/revive-...
[2]: http://updates-http.cdn-apple.com/2021WinterFCS/fullrestores...
(shasum 7315f657df2a14b838b9d51eb49cdfff5be090e7)
The SSD on these Macs contains system firmware, including the boot picker and recovery mode. Do not wipe the entire top-level block device. They cannot boot from external media, by design.
M1 Macs are not PCs, and you shouldn't blindly apply whatever you think you know from the PC world. Their low-level design is much closer to an embedded device like a Raspberry Pi, minus the SD card slot. https://github.com/AsahiLinux/docs/wiki/M1-vs.-PC-Boot
It's hard to truly brick these things (you need to wipe NOR flash for that, and even then Apple can fix it without taking them apart, but you can't, because if you wipe NOR flash calibration data is gone and it has to go back through part of the manufacturing test process), but wiping the entire SSD isn't going to help you. If you start messing at that level, you'd better be prepared with another Mac and Apple Configurator 2 to get a proper clean start.
...or like a iPhone.
From that article you linked:
Some PC motherboards implement a similar feature as part of a separate chip, which can flash the UEFI firmware from a USB stick without actually turning on the motherboard normally, but this is only common in higher-end stand alone motherboards.
That might be referring to boot-block recovery, and I haven't seen any with a "separate chip" besides the dual-BIOS type; it's in the same flash (just a normally write-protected part) as the rest of the BIOS. The older ones will look for a flashable ROM image on the first floppy drive, but I'm not surprised if the newer ones will do it with USB instead.
Because modern bios flashback does indeed read from the USB and write to one of the bios chips without even the CPU in place. Obviously there is some form of micro-controller performing this.
On intel, I suppose it would be possible for the management engine CPU in the chipset to do this, but I doubt intel lets motherboard makers run custom code on that, so if it is not some standardized feature, it could not be that. On AMD Ryzen, I'm not aware of a CPU in the chipset.
This all makes me think there is some other microcontroller somewhere that controls the bios flashback process, which would almost certainly be an extra chip.
It's back to the Apple Store for you.
While architecturally simpler (and probably more secure by allowing the network stack to be removed from the low-level boot infrastructure?), the disadvantage is that you can mess up the 1TR partition. If you do, the only way to recover the machine is to do a DFU restore from another Mac via Apple Configurator. That's not terribly convenient if you don't have another Mac around. (An Apple Store can DFU restore for you, but last I checked Apple Stores are appointment-only due to COVID and it's almost impossible to get an appointment there these days.)
> Nope, this don’t work as I suspected… so, let’s check online, Apple suggests a long procedure and a short by typing “resetpassword” in terminal, that was a chance but since it founds no users, there’s no passwords to reset.
"resetpassword" opens Recovery Assistant. Recovery Assistant is primarily intended to provide a "forgot password" flow, which is why it wants to identify a user. However, in the app menu bar, there is an option called "Erase Mac." That is how you do a full secure erase of an M1 Mac. It will work without any user, and even without any OS install at all. (I have tested this myself by erasing a machine multiple times without reinstalling the OS.)
I like Macs having iPad-like performance, but I don't like the boot process is so locked down that it reminds me this computer belongs to Apple, not me.
I have no time to go through the thorns and landmines over incompatible systems or buggy system software tools from Apple as described by the blog post.
Again, I will wait until the software on Apple Silicon is mature and the developer ecosystem catches up to it which by then I'll be getting an M2 or M3 based Mac.
I was able to fully erase and install OS X from recovery 5 times. My biggest issue was time machine. I opened a support ticket and they took a bunch of logs.
It's also much quicker than Windows 10's "Reset this PC" functionality, which doesn't work at all if the OS or firmware is hosed.
I got stuck with almost the same issue even though I'm system administrator and programmer with decade of experience. I can't imagine how all this mess should feel for average Mac or Windows user.
This works from the GUI Disk Utility too, usually, though that tool is flaky sometimes. It definitely works from the command line.
Reminds me of the endless reinstalls I had to do of windows back in the 2000s and the anxiety of it all working again once it was back running. So glad that isn't necessary anymore.
I genuinely still have my 25 digit windows 98 license key memorised from having to reinstall it so many times.
You could fix it by hand or you could do a fresh install - which would also wipe out any errant startup programs, etc.
Just asking for a friend.
Every MacOS update is a minefield. We have a dedicated Slack channel at work where people discuss if they dare to upgrade yet, and share which software now is breaking on their computers, warning others to wait.
So this arrived in September 2020. What I want to know is if normal Apple users, i.e. not programmers, whether they can benefit from webP images yet, when using the default Safari browser.
I have no idea in this pandemic about basic things.
P.S. T2 Macs are actually the most difficult to restore to the latest OS sometimes. The installer is anal about asking local password, booting from external USB, etc. and you might end up having to go through internet restore once and then upgrade the OS. M1 is actually an improvement and simplification from clean OS install perspective.
If an issue takes less than 5 different attempts to resolve and under 1-2 hours to fix, that can't really be called painful, merely annoying. Especially when it's only a one-time problem.
When the resolution means that you need another Mac at hand it is not merely annoying if you don't.
If your bar is "It just works", then for me at least, if it takes me more than 1 minute I'd describe it as painful. My mother would describe anything that's not immediately obvious as painful.