Is it possible to change the inode of a file. What are the different conditions when the inode of a file can be changed ?
Asked
Active
Viewed 7,181 times
4
-
Why do files sometimes change but not the inode or vice versa? is related, but not a duplicate — why files sometimes change inode behind the scenes, vs can you explicitly change the inode. – Gilles 'SO- stop being evil' Feb 18 '17 at 23:51
1 Answers
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 withcp -a
to the original location, it will have the same inode as the first file. – Alireza Mohamadi Sep 19 '21 at 08:50