1

My question begins with: Do I actually have hard links on my disk at all (except for "." and ".." of course)? I'm not sure how I would find that out?

If no, the question is already answered.

If yes, I'd like to adjust my backup routine (currently using rsync -a) to preserve my hard links. I've seen the option -H, but the man page worries me with a few statements, e.g.:

-a, --archive
    ...
    Note that  -a  does not preserve hardlinks, because finding 
    multiply-linked files is expensive...

-H, --hard-links 
    ...
    It does NOT currently endeavor to break already existing hard links 
    on the destination that do not exist between the source files. ...

    Note that rsync can only detect hard links between files that are 
    inside the transfer set...

So what should I do, if I have hard links on my disk?

1 Answer 1

2

If you have a standard distribution you will have few hard links , so you generally don't need to worry too much. /bin, sbin, /lib/modules, and /usr have a bunch of hard links so if you are backing them up you may want to use the -H option. Backup directories may also contain hard links. Otherwise, you shouldn't have hard links unless you create them yourself.

To find directories with hard linked files try the command (substitute / with other mount points if needed):

sudo find / -xdev ! -links 1 ! -type d | xargs -n 1 dirname | sort -u
2
  • Thanks! All sudo find / -xdev ! -links 1 ! -type d found for me are hard links between some cups files: /usr/lib/cups/backend/lpd - /usr/lib/cups/backend-available/lpd. Should I expect negative side effects, if they aren't restored correctly after a backup restore? (I just realized, that I already did a backup restore some time ago, which is maybe the reason why I don't have more hard links...) Jul 10, 2011 at 14:54
  • You shouldn't expect negative side effects other than increased disk usage. The links should be replaced if you reinstall the related packages. This might happen if you patch something. New /lib/modules directories get created when a new kernel patch is installed. cups uses a hardlink, where most applications would use a symbolic link. This is a rare occurance.
    – BillThor
    Jul 10, 2011 at 15:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .