Skip to content

Hardlink instead of rsync #14

Description

@PeterNerlich

I am not well-versed in that matter, but I had the thought whether hardlinking the files would actually be a better idea.

From what I think I understand, hardlinks are directory entries that point to the same inode already referenced in another directory and/or entry. Inodes have a reference counter, so when deleting a file (path), the corresponding entry is removed and the actual inode is only really deleted if it has no more references. Does this behaviour differ in different file systems?
The only reason to use plain cp or rsync or otherwise creating new inodes with the same content then is to either then modify the independent copy, or when the two locations are on different file systems, right?

In case that all holds true, and if my assumption is correct that we expect the number of cases where /usr/lib/modules/backup/ somehow is a different file system to be negligible, then it would be a much better idea to just hardlink all the files with cp -lr: It doesn't use more space and is much faster because only directory entries are written. Being deleted should not erase the data because of the reference counter and restoring the modules will be the same, just the other way around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions