$ sudo fsck_apfs -ln /dev/disk1s1
Let me explain this in details:
- sudo - assume admin rights
- fsck_apfs - the low level program to check an APFS file system
- -ln - scan this in "live mode" and do "no changes"
- /dev/disk1s1 - the name of your main disk. You can find this by either doing a "df ~" or "diskutil list". The later gives the following output on my system:
$ diskutil list
/dev/disk0 (internal):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme 500.3 GB disk0
1: EFI EFI 314.6 MB disk0s1
2: Apple_APFS Container disk1 500.0 GB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +500.0 GB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD 478.9 GB disk1s1
2: APFS Volume Preboot 47.5 MB disk1s2
3: APFS Volume Recovery 512.8 MB disk1s3
4: APFS Volume VM 1.1 GB disk1s4
If this tells you that you should repair your disk, you must boot your Mac into single user mode (console mode). To do this, reboot and press CMD+S during reboot. You will get a unix console with a root prompt.
here you can run
# fsck_apfs -y /dev/disk1s1
-y means here: repair without asking