Deleting and Hard Links

Status
Not open for further replies.

Vivan

Dabbler
Joined
Aug 11, 2015
Messages
24
Hi,

So I've got a question about Hard Links - if I create a hard link to a file and then delete the file, I know that the hard link still works as it is actually to the inode and not the "file". However, once I delete that hard link, how can I be sure that the inode has been freed up and that the file is not sitting in some now reserved space on the filesystem? Looking at space usage, the capacity did not change when I deleted the second hard link, though there should have been no hard links to that file and therefore it should have been considered deleted.

Also, is there any functional difference between moving a file and creating a hard link then "deleting" the original file?
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
When you delete a file it decrements a reference count for that file. Once that reference count is zero the file is deleted. You shouldn't really have to 'be sure' it got deleted, it's the os's job to do that and it "always" works.

Yes there is a difference between moving a file and hardlink then delete but in the end it will be the same. One thing to note is you can't hardlink across filesystem's. You mention inodes and these are specific to a filesystem so can't be shared with other filesystem's.
 
Status
Not open for further replies.
Top