Files in *nix filesystems almost always have an associated inode number. In most cases users seem not to deal very much with those inode numbers, as they use filenames (i.e. a hierarchical pathnames-filename structure) to interact with the file. Hence renaming a filename is frequently happening
mv oldname newname
How would be a renaming (reassigning) from one to another inode number work?
The background is that I want to backup (i.e., and restore/ catalogue) files from my filesystem. At restore I would be happy to see former inode #7 to become again the lucky inode #7.
Knowing that the kernel's filesystem handling may abstract the handling of inodes, I assume that sometimes another file is given #7 before the one I wanted to assign it to. In short I expect the decision "dear kernel change inode #12345 to #7" to get into trouble when #7 is already taken. Even though—as comparing with filenames—also filenames are unique and when wanting to rename a file to an already used filename I would go about like this:
mv newname othername mv oldname newname
By the above I was able to have the file
oldfile renamed into
newname besides having to deal with previously also renaming the previous
Consequently I am confident a way to change/ influence the inode number might exist. In which case this would answer the question perfectly. In case it is somewhat filesystem dependent, I would most like to know it for ext4.
My negligence let me overlook https://stackoverflow.com/questions/5752822/how-do-i-create-a-file-with-a-specific-inode-number which addresses much of the same question. Being SO and not Unix&Linux I am unsure whether it would not be adequate to leave this question here, or delete it. Yet there being already one answer?