Can't boot from external APFS formatted SSD
I have a Mac mini with macOS High Sierra and an external SSD drive connected via USB also with High Sierra on it.
After converting the external SSD to APFS it doesn't boot anymore - my Mac can't see it as bootable and doesn't show it when booting with holding Option key.
If I go to System Preferences -> Startup Disk and choose the external drive I get an error:
You can’t change the startup disk to the selected disk.
Running bless to place boot files failed.
It seems that macOS can't install some boot files on that disk. Running First Aid on that disk in Disk Utility also produces an error:
Verifying allocated space.
error: Underallocation Detected on Main device: (7219537+1) bitmap address (184373)
Space Verification failed.
The volume /dev/disk1s2 could not be verified completely.
What can I do to restore those boot files and make the SSD finally work? I don't want to erase it and reinstall.
Solution 1:
Answering my own question... (happens a lot to me lately)
I did manage to get it to boot from the broken SSD by first booting from a USB drive I prepared earlier with High Sierra install files on it and then installing to the SSD drive on top of the old system.
There was a weird thing happening during first reboot after the installation where my screen would flash and turn off. In fact I think I didn't really finish the installation, I think the installer didn't even copy all the files, but everything seems to work fine now so I'm pretty happy (and my old files and apps are in place).