Issue solved; no physical errors.
These are what I did:
First I analyzed where the error occurred :
...
** Checking catalog file.
Invalid index key
(4, 20220)
Invalid node structure
(4, 38065)
The volume SSD could not be verified completely.
...
fsck
stops while scanning catalog files. Let's try reading fsck_hfs
user manual by executing man fsck_hfs
for clues.
...
-R flags Rebuilds the requested btree. The following flags are supported:
a Attribute btree
c Catalog btree
e Extents overflow btree
...
Let's try rebuilding catalog btree then. fsck_hfs -Rc /dev/rdisk0s2
Results: fsck
does not stop at catalog file check anymore, and the Invalid index key
error disappeared, revealing more errors ( clues! ).
** Checking extents overflow file.
Incorrect block count for file Cache.db-wal
(It should be 114 instead of 119)
** Checking catalog file.
Missing thread record (id = 30291961)
Incorrect number of thread records
Incorrect number of thread records
** Checking multi-linked files
** Checking catalog hierarchy.
Invalid directory item count
(It should be 221 instead of 244)
Invalid volume file count
(It should be 1318081 instead of 1318117)
** Checking extended attributes file.
Invalid node structure
The volume SSD could not be verified completely.
fsck
now stops when checking extended attributes file. Let's try rebuilding the attributes btree with fsck -Ra /dev/rdisk0s2
.
Result(s): All errors, except Invalid node structure
disappeared after the first repair attempt. It shows several invalid nodes, then attempts the second repair, and rechecks. It still shows some invalid nodes, but even less then before.
However the fsck
stops with a message saying that it stops making repair attempts after 3 check failures. I ran fsck -Ra /dev/rdisk0s2
again. It attempts to repair again, then rechecks. No invalid node structure error shows up!
It now makes Invalid volume free blocks count
, Invalid volume file count
, and Invalid volume directory count
errors, but it doesn't stop yet!
After yet another attempt of repair, fsck
finished without any errors.
Shut down. Boot normally without entering single user mode. And it works!
Problem solved by running fsck
several times, rebuilding catalog btree, and attribute btree several times.
Though the following should be valid for non-encrypted volumes and unlocked encrypted volumes, it doesn't help much because the main volume here is encrypted and locked. So skip to FileVault2-encrypted volumes
Non-encrypted volumes
Almost no free space on your start volume is a problem. At least 10 % free space are recommended.
It's indeed possible to remove files & folder in Recovery Mode but if you have an external disk/thumb drive (hfs+ or fat32-formatted) you may move them instead:
- attach your external device (if you have one).
- If FileVault2 is enabled on your main volume start Disk Utility, right click the volume and unlock it
- Quit Disk Utility and open /Utilities/Terminal in the menubar
- enter
cd /Volumes/NameOfYourMainVolume/Users/accountname
to change to your user folder (example: cd "/Volumes/Macintosh HD/Users/ausername"
).
To get the names/mountpoints of your main volume/external disk enter diskutil list
or df
.
enter ls -la
to show all files and folders
Example:
drwxr-xr-x+ 56 ausername staff 1904 20 Feb 23:45 .
drwxr-xr-x+ 7 root admin 238 15 Jun 2012 ..
-rw------- 1 ausername staff 3 21 Nov 16:11 .CFUserTextEncoding
-rw-r--r--@ 1 ausername staff 43012 20 Feb 23:35 .DS_Store
drwxr-xr-x+ 3 ausername staff 102 15 Feb 17:41 .TemporaryItems
drwxr-xr-x 4 ausername staff 136 2 Nov 23:22 SomeFolder
- now move further with
cd SomeFolder
enter ls -la
to show all files and folders
Example:
drwxr-xr-x+ 7 ausername staff 238 15 Jun 2012 ..
-rw------- 1 ausername staff 4736527884 16 Okt 22:33 BigFile.mov
drwxr-xr-x 4 ausername staff 136 2 Nov 23:22 UnwantedFolder
to move BigFile.mov to your external device enter
mv BigFile.mov /Volumes/ExternalDevice/
or to move UnwantedFolder to your external device enter
mv UnwantedFolder /Volumes/ExternalDevice/
.
if you don't have an external drive remove folders and files with rm -dr UnwantedFolder
to remove UnwantedFolder and all its content or rm BigFile.mov
to remove BigFile.mov (4.7 GB in the example above). rm *.mov
removes all .mov files in your working directory.
rm is a powerful command to delete a file or directory without confirmation by default. Because of this behavior, users should really be sure before deleting files or folders. So double check where you are - enter pwd to print your working directory - and what you want to delete!
FileVault2-encrypted volumes
started to Recovery Mode open Disk Utility
If you had one partition spanning your whole hard drive and encrypted it with FileVault2 it's completely normal that you have only some MB available space left. That's unallocated free space on your hard drive. In the example above 12,7 MB are left.
highlight your FileVault2 volume and unlock it.
enter the FileVault password
if you succeed and the encrypted volume isn't corrupted your FileVault2 volume will be mounted. Check the available free space. In the example below the availbale free space on the volume is 52,8 GB
If the unlocking fails - using the correct password - the FileVault2 volume probably is corrupted. The only possible solution then is completely erase/repartition the hard drive and restore a backup.
Best Answer
The folder icon with question mark that you're seeing appears when no bootable media is found, and in your case seems indicative of SATA cable failure or hard drive failure. Your local Apple Store can help diagnose this (they have a more thorough in-house hardware test OS that isn't publicly available), but I'd place my bets on cable failure, given your symptoms and how failure-prone they are known to be.
If it's just the cable, they can replace it for you (typically £100 for parts and labour), or you can get the part and tools for around £15 and replace it yourself if you have the time and patience. If it's the hard drive itself, you'll obviously need to replace it, and your data is likely lost — in this situation, don't attempt to recover the data yourself; you'll do more harm than good. Instead, consult a data recovery specialist if you desperately need the data and don't have a backup.
To attempt some better diagnostics at home, make a bootable Ubuntu USB and see if that detects your drive. I've had some luck in the past with that, in situations where a SATA cable has failed sufficiently that the Mac EFI and macOS (including Recovery) refuse to show it, but Linux will do its best to provide info. When in Ubuntu, open the Disks app to see if your drive is detected. If it is, check the SMART report (select the disk in the left sidebar, click the three-line icon in the upper-right, click "SMART Data & Self-Tests...") If all is reported good, the cable is almost certainly the issue.
P.S. "obviously I can’t repair a disk that doesn’t appear in [Disk Utility]" — Likewise, you cannot use
fsck
to check a filesystem that the OS cannot see, hence why it says everything is fine.