0

Let's say that I created a file. A new inode has created. Then I created a soft link to that file, and deleted the hard link.

Does the inode still exist? Does it point to the same location in the memory? Is the soft link connected to the inode that is connected to the memory, and that's the reason for not finding the file, or does the soft link lose its connection to the inode?

Thank you.

tk421
  • 5,775
  • 6
  • 23
  • 34
Asher
  • 57
  • 1
  • 7

2 Answers2

1

The inode will be gone. The inode will continue to exist as long you have at least one hard link. A soft link will have no effect. A soft link is in fact a separate file. A hard link is another pointer to the same file. Once the hard link count goes to zero, the inode is deleted.

As long as the memory is not over-written, it will continue to exist (and so disk recovery tools will be able to get at it), but as far as the operating system is considered, the memory is available for reuse.

Sean F
  • 4,344
  • 16
  • 30
1

This is offtopic and more than one question, but:

A softlink in Linux is not connected to an inode. It only have the name of the file (see the size of the softlink? it is the length of the name is links to!). Even renaming the original will break the link.

[bart@localhost link]$ touch foo
[bart@localhost link]$ ln -s foo bar
[bart@localhost link]$ ls -la
lrwxrwxrwx   1 bart bart    3 Dec 13 21:09 bar -> foo
-rw-rw-r--   1 bart bart    0 Dec 13 21:09 foo
[bart@localhost link]$ mv foo foo2
[bart@localhost link]$ ls -la
lrwxrwxrwx   1 bart bart    3 Dec 13 21:09 bar -> foo
-rw-rw-r--   1 bart bart    0 Dec 13 21:09 foo2
[bart@localhost link]$ cat bar
cat: bar: No such file or directory

An inode is gone if you delete a file.

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195