bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: find inodes of a dir


From: Andrei Enshin
Subject: Re[2]: find inodes of a dir
Date: Sat, 15 Aug 2020 19:56:13 +0300

I’m using ext4:
/                                        /dev/nvme0n1p7         ext4            
rw,relatime,errors=remount-ro


The full out of find is:
$ sudo find / -xdev -inum 2 2>/dev/null  
/
/dev
/run
/var/lib/docker/containers/e1c046bb5a81c469a8df15d2120ef0279c00537034d12b16ecf662b8ee373965/mounts/shm
/var/lib/docker/containers/9deea768c8f6c63a729cfb05fdbe0c0bd94ba0a3acf5d855a90cea59f6d275cb/mounts/shm
/var/lib/docker/containers/2c84000c9de461357cb839291b8f6b85224cbf83e4a834bb2be0c07971914047/mounts/shm
/var/lib/docker/containers/f1cad304f57c9d037f5d9cdb56dc992d3838ef85456819dedf4e09dfe9f34828/mounts/shm
/var/lib/docker/containers/203d7a788ea761b0c888fd23748049136ac7c506aa67ffb4141bc41c151e0c3a/mounts/shm
/var/lib/docker/containers/65ba7611be7738ad051b6ba09cd51304dc574bab54def0b140999abdc3a299c6/mounts/shm
/var/lib/docker/containers/255a29fb2b41cd6c541d11b8cdc22e69c8aac5d0cd80b83f04295539f7d9700b/mounts/shm
/var/lib/docker/containers/ed8595232045982ed792d50cbc60ccac3c156b23e9c205c85c3a3e3c830f431d/mounts/shm
/var/lib/kubelet/pods/a994411d-8f24-4101-9e07-b15e66470dfc/volumes/kubernetes.io~secret/coredns-token-65pjr
/var/lib/kubelet/pods/e1c23a8f-c462-4562-b556-7791be24213e/volumes/kubernetes.io~secret/kube-proxy-token-clxqv
/var/lib/kubelet/pods/e8c0dbfd-3daf-4d5a-8672-8d8311ddf393/volumes/kubernetes.io~secret/flannel-token-x6nrk
/var/lib/kubelet/pods/91acd716-7fb7-4477-80ef-9aeb5774df17/volumes/kubernetes.io~secret/coredns-token-65pjr
 

  
>Saturday, August 15, 2020 7:48 PM +03:00 from Martin Schulte 
><gnu@schrader-schulte.de>:
> 
>Hi Andrei!
> 
>> I’m trying to identify all hard links pointing to my root directory:
>> $ sudo ls -lid /
>> 2 drwxr-xr-x 23 root root 4096 Aug 11 20:58 /
>>
>> The inode number is 2 and count of hard links is 23.
>>
>> Then I run find:
>>
>> $ sudo find / -xdev -inum 2 2>/dev/null | wc -l
>> 15
>I'm rather astonished that you find 15 and not only one...
>
>First of all these results might depend on the type of underlying filesystem - 
>I'm answering for a "classical" Unix filesystem, I'm using with ext4 here.
>
>Keep in mind that there you can't "manually" create hard links to a directory, 
>the only way to increase the link count of a directory is to create a 
>subdirectory in it.
>
>In the directory where you created a directory "dir" you have one link to the 
>directory. Inside "dir", "." is the second link, and for each direct 
>subdirectory of dir ".." is another.
>
>$ ls -lid dir dir/. dir/sub1/.. dir/sub2/.. dir/sub3/..
>13918312 drwxr-x--- 5 schulte schulte 4096 Aug 15 18:40 dir
>13918312 drwxr-x--- 5 schulte schulte 4096 Aug 15 18:40 dir/.
>13918312 drwxr-x--- 5 schulte schulte 4096 Aug 15 18:40 dir/sub1/..
>13918312 drwxr-x--- 5 schulte schulte 4096 Aug 15 18:40 dir/sub2/..
>13918312 drwxr-x--- 5 schulte schulte 4096 Aug 15 18:40 dir/sub3/..
>
>Formula: Link-of a directory = 2 + number of direct subdirectory
>
>Thus your link-count of 23 should just mean that you have 21 subdirectories in 
>your root directory.
>
>There an exception with / - since there's on directory above it both . and .. 
>have the same inode.
>
>Since find will not find .., it will only get one entry:
>
>$ sudo find / -xdev -inum 2 -exec ls -lid {} \;
>2 drwxr-xr-x 23 root root 4096 Jul 19 10:42 /
>
>For further analysis it would be helpful that you sent us the type of the 
>filesystems you are working on and the whole output of the find, not that one 
>pipe trought 'wc -l'.
>
>Best regards
>
>Martin 
 
 
---
Best Regards,
Andrei Enshin
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]