I'm running macOS Mojave on a late-2015 4k 21.5" iMac.
I have lost access to my internal hard drive, but I can use my iMac by running macOS from an external drive or through recovery mode.
When I hold down the option key on boot, the only available drive shown is my external one. Last time I tried booting without holding option, I was greeted by the folder icon with the question mark in it.
I have not deleted my data, not even accidentally, it is all still there and I can see it using iBoysoft APFS data recovery.
This problem started when I tried to install Ubuntu on a partition using this guide https://www.maketecheasier.com/install-dual-boot-ubuntu-mac/ (I tried to follow all the steps carefully, but I may have made a mistake) and afterwards in Disk Utility my drive was called
FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF. My Mac was still running fine, but when I restarted it, it would no longer boot into macOS. I searched the internet for this problem and any solutions and I found a few. I went through these guides and did as they said, and I'm pretty confident I changed the numbers for sizes etc. correctly for my own situation, but even after following these guides I still cannot boot into macOS on my internal HD.
My HD is 1TB, my mac partition is 960GB, my Ubuntu one was 40GB but I deleted that and installed macOS Sierra on it, but that disappeared at some point too.
I managed to get my Mac to recognise that the data is in APFS format and that it's actually there, it just wont interact with it outside of terminal.
My APFS partition doesn't seem to have a container, as far as I understand APFS (not very far), it needs a container. I did not delete the container but I think it has been lost. Maybe it need to be rebuilt or the APFS partition needs to be put in one somehow, but I don't know how to do either of those things.
Another note is that the partition was 960GB but now shows as 883GB - I don't know what this means, that may have been the amount of data on the partition, but that seems maybe a little high.
I'm not nearly good enough with macOS or terminal to be messing around with it without help and I probably shouldn't have tried to install Ubuntu on my main hard drive without a recent backup, but I could really do with some help and I'd appreciate it a lot.
here are the results of some terminal commands, they will be more reliable than my guesses and explanations:
(disk0 is my internal HD, disk1 & disk2 are just the external USB drive I installed macOS on so that I can still use my iMac)
sudo gpt -r show disk0
sudo dd if=/dev/disk0 bs=512 count=1 skip=409640 | hexdump -Cv
sudo dd if=/dev/disk0 bs=512 count=1 skip=228482040 | hexdump -Cv
Edit 20/10 22:30: After trying to mount or repair the volumes of disk0 in any way I could on my USB drive macOS install, I gave booting into recovery mode another try. I tried repairing in Disk Utility, but it told me I needed to do that in recovery mode (I was in recovery mode) and told me to press continue and nothing happened, so I used diskutil repairvolume in the recovery terminal and it said something about how I couldn't because my APFS volume doesn't have a container (other diskutil commands told me that it wasn't an APFS volume or didn't even use APFS, so I think its lack of container was giving my computer a hard time). I looked around some more, searching the error messages I got, and came up pretty empty (it doesn't help that APFS is relatively new and so is Mojave). So now I'm currently running some APFS data recovery software (Disk Drill) so I can do a fresh install of macOS on my iMac internal HD and just import my recovered old data onto it. Before I wipe my internal HD I'll try fixing it in single user mode with '/sbin/fsck -fy', but I'm not hopeful. This will presumably take at least a day though, and may not work out as planned, so if anyone can provide me with a way of creating an APFS container and putting my APFS volume into it so that my system can read it, that would be great. If you need the results of terminal used in recovery mode, I can do that, but unless there's a way of capturing screenshots in recovery mode, they'll be photos of a screen.
Current 'diskutil list disk0' and 'sudo gpt -r show disk0' results
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_Boot 650.0 MB disk0s2
3: Apple_APFS 883.2 GB disk0s3
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
227212504 1269536 2 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
228482040 1725043095 3 GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
1953525135 32 Sec GPT table
1953525167 1 Sec GPT header
Thank you for any help or suggestions