LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How can a dir have 17 non-hard non-sym links (https://www.linuxquestions.org/questions/linux-general-1/how-can-a-dir-have-17-non-hard-non-sym-links-4175571541/)

ballsystemlord 02-05-2016 12:56 PM

How can a dir have 17 non-hard non-sym links
 
So, I found a dir whose absolute path is /var/cache with the following stat info:
Code:

  File: '/var/cache'
  Size: 4096            Blocks: 8          IO Block: 4096  directory
Device: 803h/2051d      Inode: 3850482    Links: 17
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2016-01-05 22:39:57.751115545 -0500
Modify: 2016-01-19 23:01:47.215809957 -0500
Change: 2016-01-19 23:01:47.215809957 -0500
 Birth: -

I wanted to move the said dir to another file system. The problem is that I can't figure out where it links to. The file system it's on is ext4 (don't know if it makes a difference.)
I executed
Code:

find /etc /usr /var /run /bin /sbin /lib64 /tmp /opt -samefile /var/cache; find -L /etc /usr /var /run /bin /sbin /lib64 /tmp /opt -samefile /var/cache
I also tried the same with the inode number.
I see simmilar for other dirs too / has 27 links.
Perhaps these are in proc?

astrogeek 02-05-2016 01:38 PM

There will be a hard link for (at least) each of the following...

* The directory name, directory
* The directory name, directory/
* The directory self reference, directory/.
* The parent reference of all sub-directories, directory/subdir/..

That can be a lot of links!

rknichols 02-05-2016 02:22 PM

A directory will always have at least 2 hard links. Those are the link from the parent directory and the "." link to itself. Each immediate subdirectory also has a ".." link back to its parent. Those are the only permitted hard links to a directory. Any others constitute filesystem corruption. A link count of 17 just means that there are 15 subdirectories. You can go ahead and move that whole /var/cache tree with no problem.

Or, just throw it away. After all, it's just a cache and will be repopulated automatically. About the only thing that might be worth keeping are the packages that were downloaded for installing/updating, and that's only if you have keepackages set for one or more repos.

ballsystemlord 02-09-2016 09:57 PM

[solved]
 
Thanks, I was over thinking that one :redface: (takes gun, points at foot, changes mind, starts writing C).


All times are GMT -5. The time now is 04:23 PM.