Does inode number get changed when upgraded to APFS during OS upgrade?

Does inode number remain same across file system upgrade ? ( HFS to APFS)


I am asking this question since I am using the inode number to uniquely identify the file across reboots. If inode gets changed after upgrade to APFS, functionality which relies on inode number might not work.


I observed that upgrading a HFS formatted DMG to APFS retains the inode number.

Replies

Last I checked the upgrade preserves the inode number (this produces some oddities because the inode numbers of a converted volume look very different from the inode numbers of a native volume).

I am asking this question since I am using the inode number to uniquely identify the file across reboots.

There’s two ways to look at this:

  • If you’re tracking a small number of files, you should use a bookmark. This handles lots of edge cases that are otherwise difficult to deal with (for example, it will work across backup and restore).

  • If you’re tracking a vast number of files, storing a bookmark for each is going to be too expensive. In that case using the inode number is fine, but you have to have a way to deal with the inode numbers becoming invalid (for example, the above-mentioned backup and restore case).

A good example of the latter is Spotlight. Its index uses the inode number to keep track of files, but it is able to rebuild this index if things goes south.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Quinn for detailed reponse. I would probably have to use inode number in that case and deal with restore/backup cases, as I process large number of files.