Quote:
Originally Posted by
fhill2
is it possible to change the inode value/ file path of a hard link?
Why do you care what i-node number is assigned to a file?
Of course it is possible. All you have to do is figure out the structure of the filesystem used to store the file and dig into the bits on disk and in the kernel's memory (if the file is open, or any of its data is cached) to change the filesystem's idea of what the i-node is for that file. Depending on the filesystem type, that might mean changing a few bits in one location, or it might mean changing lots of blocks. Using this method, you could change the i-node to be any unused i-node number available in that filesystem. (Note that if you don't already know how to do this, it is not something you should even consider trying; if you do it wrong, you may lose all of the data on that filesystem. And, if it is cached in the kernel and you get it wrong there, you may lose all of the data on all of your filesystems.)
More portably, you could copy the file to another name and then rename the new file to have the name of the old file. This will create a new file with a different i-node number and then remove the old link to the old i-node number. Of course, if there were multiple hard links to the old name, the other links will remain unchanged. If you want them to be linked to the new i-node number, you'll have to find all of the old links, unlink them and then link them to the new file. Using this method, the i-node number will be different, but you will not be able to specify what the new i-node number will be.