Back up all important data first
Open Disk Utility
Select the HDD from the sidebar
Click First Aid and run it on the disk and each volume
If First Aid fails, boot into macOS Recovery
Open Disk Utility from Recovery
Select the HDD and try First Aid again
If the partition map is damaged, erase the disk and recreate the partitions
Use the Erase option to choose the correct format and scheme
Reinstall macOS if the disk is your startup drive
If the drive is external, disconnect and reconnect it
Try a different cable, port, or enclosure
Check the drive in Terminal with diskutil list
Use diskutil repairDisk on the affected drive if needed
If the drive is failing, replace it
Restore your data from backup after repairs or reformatting
