Some Notes on MacOS brew and APFSLast update: a year ago Tag : macos, apfs, brew
Brew is the de facto package manager for macOS, especially for a developer. Most of the time we just do
brew update && brew upgrade and quickly
brew cleanup after those routine. Rarely we have no problem of doing that, i.e updating the software to the latest stable version.
Sometimes, we just need to revert back to the old version, as there are one or two libraries which are not ready yet for the latest version. For example, here I have the latest python 3.7, in which many of my libs are not there yet. So, how to go back to python 3.6?
If you don't cleanup the brew yet, you can just run
brew switch python 3.6.5_1. Usually we have no reason to keep old software around when we already have the new one. For that case, we need to install the old first, and then do the switch:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.r and then
brew switch python 3.6.5_1.
You can find more on the brew tips and trick right from the website.
Second thing I recently have is apfs partition problem. I have two or three operating system in my laptop, so it's common for me to resize and redistribute the free space among those OSes. The only problem is APFS sometimes just refuse to boot after this resize from third party partition tools. If we check the partition info, sometimes the APFS partition type changed to windows recovery, which is why the macOS booter just show the cool stop sign, as it couldn't find the location of the bootstraps files.
So, to resolve this partition type changing, we need to delete that partition, and re-add the same exact partition with its beginning location and size and the correct partition type.
Note that we can do this only from another disk, or via USB macos Installer, or macos recovery.
First, we need to list the partition of the disk:
gpt -r show /dev/disk1 (you can change the disk1 to your actual disk).
Next, remove the partition and re-add it:
gpt remove -i 2 /dev/disk1 (second partition)
diskutil unmountDisk /dev/disk1
gpt add -i 2 -b <beginning of the sector> -s <part size> -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk1
diskutil verifyVolume /dev/disk1s2
Then we can just continue to boot to that APFS partition.