Is there a way to completely remove an inode when the Link count is 2 ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is there a way to completely remove an inode when the Link count is 2 ?
# 1  
Old 04-12-2011
Is there a way to completely remove an inode when the Link count is 2 ?

Currently my data is organised in a volume which has a cache directory (where all the files are first created or transferred). After that there are suitable directories on the volume which in their subdirs, contain files hardlinked to files in the cache. This is done so that the same inode (file) can be hardlinked multiple times in multiple directories.


Now when trying to clean up the volume, I recurively go through the dirs(not the cache) and based on certain criterion, unlink the files (which basically reduces the inode count of the cache entry by 1). Is there a way for me to delete the cache entry directly, when I am deleting the last hardlink (that is bringing down the count from 2 to 1). This way I would not have to manually parse through the whole cache directory to clear any inodes from it, which have a link count of just 1.


I have gone through unlink/remove functions, and could not find anything specific of use. Is there some purging algorithm that internally takes care of this, then I can try to implement that.
Any help on this would be highly appreciated. In anticipation of a prompt reply.
# 2  
Old 04-12-2011
You have to search the mount and find both inode entries in 2 directories and unlink (remove) them. But perhaps you mean hw to clean cache of 1 link files? You can:
Code:
find xxx -type f -links 1 | xargs -n999 rm -f


Last edited by radoulov; 04-12-2011 at 04:34 PM.. Reason: Fixed code tags.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Zero link count files in proc

Hi Experts, I had encountered an issue where the zero link process was holding too much amount of data on a Solaris server. I was able to terminate the process after which the space of the file system was released. 40G /proc/8567/fd/2 Can you please let me know if there are any... (11 Replies)
Discussion started by: dhanu1985
11 Replies

2. Red Hat

How to remove symbolic link?

this is my current code, # ln -s /lib64/ # ls -lrth total 80K -rw-r--r--. 1 root root 12K Jul 6 2012 post-install -rw-r--r--. 1 root root 552 Jul 6 2012 post-install.log -rw-------. 1 root root 1.5K Aug 21 2012 anaconda-ks.cfg drwxr-xr-x. 2 root root 4.0K Aug 21 2012 Videos... (3 Replies)
Discussion started by: jediwannabe
3 Replies

3. UNIX for Dummies Questions & Answers

Reduce system inode count

I have lots of space on my system. linux-e30c:~ # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 41G 3.4G 35G 9% / /dev/sda3 91G 36G 51G 42% /home /dev/sda2 99G 3.4G 91G 4% /usr But still somehow the inode count has almost finished... (3 Replies)
Discussion started by: rupeshkp728
3 Replies

4. Linux

Getting warning that hard link count is wrong

I run a find command to search from root directory. find / -inum 344334 The output gives the below warning: find: WARNING: Hard link count is wrong for /proc/1. This may be a bug in your filesystem driver. Automatically turning on find's -noleaf option. Earlier results may have failed to... (2 Replies)
Discussion started by: ravisingh
2 Replies

5. Shell Programming and Scripting

how to remove soft link

hi i have create a soft link using below command. ln -s <filename> <dirmane>where file name i use is t1 and dir name was t2. i deleted the dir t2 using command rm -rf to remove the soft link . however again i create a file a using the name t2 and when i just try to link t1 to t2 ... (1 Reply)
Discussion started by: scriptor
1 Replies

6. UNIX for Advanced & Expert Users

remove file/inode entry

Hello all, I am on hpux itanium 11.31...and we run a oracle DB on it. I am testing some backup and restore situation.... first i select some data from the DB.....now i remove some files from the DB where my data is being selected from.....now i select the same data from the DB but i still get... (5 Replies)
Discussion started by: abdul.irfan2
5 Replies

7. Solaris

How to remove soft link safely

Greetings, I need some help performing a system admin function that I have been tasked with. The request seems simple enough, but my feeling is that it might be more complicated than it seems. Here is what i've been tasked with: SunOS 5.10 Generic_142900-15 sun4u sparc SUNW,SPARC-Enterprise... (3 Replies)
Discussion started by: Harleyrci
3 Replies

8. Solaris

Impact of zero link count files in proc

Greetings I want to confirm about HUGE and old files with linkcount 0 in proc file system. what is their impact on size of root File system? (3 Replies)
Discussion started by: mr_os
3 Replies

9. Shell Programming and Scripting

[BASH] Remove Link from Filename

Hi there, I'm trying to make a script that downloads something, but then strips the URL for later processing. A user would input the following: ./text -install <link> Lets say the <link> is: Later on, the script would have to; unpack the file with the command: tar xvf... (6 Replies)
Discussion started by: Syekiya
6 Replies

10. Linux

Concept of link count in linux

Hi All, Please explain me the concept of link counts when you try to view the contents of any file or directory using ls command. -sh-3.00$ ls -lrt total 194 drwxr-xr-x 2 root root 4096 Aug 12 2004 srv drwxr-xr-x 2 root root 4096 Aug 12 2004 mnt drwxr-xr-x 2 root root ... (1 Reply)
Discussion started by: vaibhav.kanchan
1 Replies
Login or Register to Ask a Question