Resolve a file’s path from its inode number
If you ever encounter an error when checking an APFS volume using First Aid in Disk Utility or fsck_apfs
, you won’t be informed of the path and name of the item responsible, but given its inode number, in an entry likewarning: inode (id 402194151): Resource Fork xattr is missing for compressed file
The inode number given can only be resolved to a path and file/folder name if you also have a second number giving the volume for that item. As that will be for the volume being checked at the time, you should be able to identify that immediately. The only time that you might struggle to do that is with items in a snapshot; those should, I think, be the same as the volume they are taken from. However, as snapshots are read-only, there’s probably little point in pursuing errors in them.
To resolve these in my free utility Mints, open its inode Resolver using the Window / Data… / Inode menu command. Drag and drop another file from the same volume onto that window.
The Resolver will then display that file’s volfs path, such as/.vol/16777242/1241014
All you need do now is paste the inode number given in the warning or error message in Disk Utility or fsck_apfs
, into the Inode Number box at the top of the Resolver window, and click the Resolve button. Mints then looks up information for that inode number on the same volume, using GetFileInfo
, and displays it below.
One drag and drop, a paste, and a click to discover what APFS is complaining about.
Command line
You’ll sometimes see Terminal’s find
command with the option -inum
recommended as a way to convert from an inode number to a regular path. Although you can do that, it’s easier to use the command GetFileInfo
instead. For that you’ll need the full volfs path, including the volume number.
To find the volume number, use my free utility Precize, and open another file on the same volume. The second line in its window gives the full volfs path for that file. Copy the start of that, leaving the second number, the inode, such as/.vol/16777238/
Alternatively, you can use the stat
command as given below.
In Terminal, typeGetFileInfo
with a space at the end, and paste the text you copied from Precize. Then copy and paste the inode number given in the First Aid warning, to assemble the whole command, such asGetFileInfo /.vol/16777238/402194151
Press Return, and after a few seconds, you should see something likefile: "/Users/hoakley/Library/Mobile Documents/com~apple~CloudDocs/backup1/0MintsSpotlightTest4syzFiles/SpotTestA.rtf"
type: "\0\0\0\0"
creator: "\0\0\0\0"
attributes: avbstclinmedz
created: 05/17/2023 08:45:00
modified: 05/17/2023 08:45:00
giving the full path and filename that you want.
GetFileInfo
is one of the oldest commands in macOS, and has been deprecated as long as anyone can remember. I suspect that Apple is still trying to work out what can substitute for it.
Get a volfs path for a file
Use Precize to run this the other way around: open the file and read the path in that second line. To copy the whole of it, press Command-2.
The simplest ways of obtaining inode numbers and so building volfs paths in Terminal are using the -i
option to the ls
command, and for individual items using stat
:ls -i
lists each item in the current directory, giving its inode number first, e.g.22084095 00swift
13679656 Microsoft User Data
22075835 Wolfram Mathematica
and so on;stat myfile.text
returns16777220 36849933 -rw-r--r-- 1 hoakley staff […] myfile.text
where the first number is the volume number, and the second is the inode number of that item, or /.vol/16777220/36849933
.