Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-04-2009, 05:29 PM   #1
LQ Newbie
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Why do hardlinks take linear time?

On the behaviour of hardlinks..: I timed how long it takes to create a series of hardlinks to a single file. The time *per hardlink creation* clearly grows linearly with the link count, regardless of whether each new hardlink is linked to the previous one or directly to the original file. The same goes for deleting them. I had expected it to take constant time, being that each hardlink just points directly to the file's inode, and the inode knows the link count but doesn't point back to all its hardlinks. So creating a new hardlink need not (cannot!) visit all the other hardlinks. Yes no?

Reason I ask is that my simple little backup cron job is gradually taking longer to run each night. It essentially just does rsync -a --delete --link-dest=... to an external hard drive. I was going to do rotating backups. But at the rate at which the EHD is filling up, I'll have bought a bigger one long before this one ever runs out of space. Delighted with the possibility of having a snapshot for every single day, I don't delete any backups at all.

Works fine, except for taking about an hour longer per week. So that's not going to be feasible. I may have to resign to a less exhaustive backup structure, though suggestions are welcome if there's a way to keep them all without taking forever per backup. Mostly I'm just curious as to why hardlinking time seems to be linear in the link count. Any ideas?

-- Javhar
Old 07-04-2009, 05:45 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
Isn't it the case that you're trying to make hard links across two different filesystems? Your internal drive and a USB doohickey? That's impossible so would result in the files being copied each time, which would explain the increase in time you're seeing. Or am I missing something critical here?
Old 07-04-2009, 06:09 PM   #3
LQ Newbie
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
It takes linear time when I try timing hardlinks on just one filesystem. Also, rsync --link-dest=... creates hardlinks on the destination filesystem itself. That's working as expected; it's not copying the files each time, as the amount of used disk space on the backup disk grows only very slowly.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
softlinks vs hardlinks irfanhab Linux - Newbie 4 02-06-2007 03:05 AM
can rsync change hardlinks instead of delete-recopy? allasso Linux - General 1 09-17-2006 11:46 AM
Cd image with hardlinks kvtournh Linux - Software 2 08-27-2006 06:22 AM
LXer: Linear Optimization with the GNU Linear Programming Kit LXer Syndicated Linux News 0 08-12-2006 05:21 AM
Lotsa hardlinks - how do I find the others? humbletech99 Linux - General 6 11-27-2005 02:27 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration