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

Re: re-linking hard links

Daniel Davidson wrote:
Hello, I have a situation where I have numerous files with numerous hard links to each of them on an ext3 RHEL4.2 system. Some of these files are duplicates of the others. I would like to re-link all of the duplicates to point to a single inode. For instance if file1 has hardlinks link1 and link2, and file2 has hardlinks link3 and link4, I need to change it so that link1, link2 (these two are already correct), file2, link3, and link4 are all hardinks to file1. The only information I have to start with are the inode numbers of file1 and file2 and the pathnames of file1 and file2.

Not sure I understand properly. It looks as though you want to compare every file on a given filesystem with every other file on that filesystem, and if they are duplicates, replace one of the actual files with a hard link to the other file.

Any ideas beyond searching all of the filenames on the system and replacing them with the proper link?

Remember that hardlinks cannot cross filesystem borders.

That takes a long time.

I suppose you could write a script that cksums all files on the filesystem, sorts the output, and verifies that two files with the same cksum are actually the same. If they are, it could ask whether it's OK to overwrite one of the files with a hardlink to the other. And yes, depending on the size of your filesystem, that would take time.

Kind regards,


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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