Need hlep with a corrupt macOS partition
To cut a long story short, I decided to dual boot macOS Monterey with Ubuntu 22.04 as I needed it for some tasks that were easier on Linux. I found Bluetooth support to be janky and had to use a wired USB keyboard and mouse to get my tasks done. So I decided I did not want to keep Ubuntu on my system long-term. The simplest solution I read online was to delete the Ubuntu partition from within macOS and remerge the volumes to recover the space. While this worked for swap, this did not work for the Ubuntu partition and I ended up with a FFFFFF on my macOS volume. Attaching the diskutil info below:
diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.1 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF 459.9 GB disk0s2
(free space) 8.1 GB -
3: Apple_HFS UNTITLED 31.6 GB disk0s4
(free space) 268.4 MB -
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +459.9 GB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD - Data 205.8 GB disk1s1
2: APFS Volume Preboot 231.3 MB disk1s2
3: APFS Volume Recovery 1.1 GB disk1s3
4: APFS Volume VM 1.1 GB disk1s4
5: APFS Volume Macintosh HD 15.4 GB disk1s5
6: APFS Snapshot com.apple.os.update-... 15.4 GB disk1s5s1
I have read some articles on apple.stackexchange to fix this but am running into more errors when I try them. Doing this https://apple.stackexchange.com/questions/451126/linux-messed-up-guid-partition-table-for-apfs-container-on-external-drive with an ubuntu live usb leads to the following error:
Found invalid GPT and valid MBR; converting MBR to GPT format in memory
Warning! Main partition table overlaps the first partition by 32 blocks! You will need to delete this partition or resize in another utility.
Warning! Secondary partition table overlaps the last partition by 33 blocks! You will need to delete this partition or resize in another utility.
Could not change partition 2’s type code to 7C3457EF-0000-11AA-AA11-00306543ECAC! Error encounter, not saving changes.
Can someone kindly give me stamp by step guide to correct this error and restore my mac to its original state with just a single partition having only macOS? My data is backed up to iCloud so if absolutely needed I can reinstall macOS from scratch. However, I would prefer to use recovery tools to solve the problem if possible.
Mac mini, macOS 12.6