4

Is it possible to change the inode of a file. What are the different conditions when the inode of a file can be changed ?

1 Answers1

4

The inode is actually what identifies the file (rather than any filename, say). That's why hardlinks work in the first place.

So the only way to change the inode number is to copy the file to a new file (which then would get a new inode).

The filesystem is responsible for managing the inodes, you can't just "choose" one you like.

dirkt
  • 32,309
  • That's not certainly true, as file system caches inodes. so if you copy your file with cp -a, delete the old file, and copy back new file with cp -a to the original location, it will have the same inode as the first file. – Alireza Mohamadi Sep 19 '21 at 08:50