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.
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
cporrsyncor 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 withcp -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.