× NETGEAR will be terminating ReadyCLOUD service by July 1st, 2023. For more details click here.
Orbi WiFi 7 RBE973
Reply

What does cp --reflink command actually do?

fb2k6
Aspirant

What does cp --reflink command actually do?

I've read about moving files more quickly within subvolumes in OS6 using the "cp -a --reflink" command in the thread shown on the bottom of this post.

I have a few questions about this command.
1) Is a physical copy actually made of the original files/folders when I use this command? I see 2 identical copies via explorer but are they independent or actually pointing to the same data on the disk?
- Reason I'm asking this is because the copy procedure was very fast on a large amount of data so I tested a txt file that was copied. I modified both with different content and I opened both and they show different content.
2) How important is it to delete the original files/folders after issuing the command?
3) If I forget to delete the original source files/folders before issuing the command, do I need to worry about data integrity when I modify the same files from each of those folders?

Thanks for any help or clarification on what "cp --reflink" actually do.

http://www.readynas.com/forum/viewtopic.php?f=21&t=76079
Message 1 of 4
StephenB
Guru

Re: What does cp --reflink command actually do?

fb2k6 wrote:
1) Is a physical copy actually made of the original files/folders when I use this command?
No. The metadata (directory information) in the source and destination folders both initially point to a single copy of the data. Note this is not the same as a symlink. A symlink is a way to have two different folders share the same file. cp --reflink creates two files that initially share the same data blocks.

fb2k6 wrote:
3) If I forget to delete the original source files/folders before issuing the command, do I need to worry about data integrity when I modify the same files from each of those folders
No. "Copy on write" means that when you modify copy A, then new data blocks are written for the parts you changed. Copy B will remain as it was. If you then change part of Copy B, new data blocks are written for them also. So from user perspective, they are two different copies.

From a system perspective, when you change copy A it becomes fragmented, and defrag cannot fix it until copy B is deleted. Also, since A and B share the same disk space, when you back up A and B the backup will take up more space than the two on-disk copies. So if you do a lot of this, you'd need a bigger backup drive than the NAS volume size. Both of these issues also apply to snapshots.

fb2k6 wrote:
2) How important is it to delete the original files/folders after issuing the command?
Deleting the originals eliminates the two system implications above.
Message 2 of 4
fb2k6
Aspirant

Re: What does cp --reflink command actually do?

Thanks StephenB for the clarification and quick response. For question 3, I actually wrote "before" instead of "after" but you answered the question I had in mind.

Also, if I delete the source files/folder via explorer instead of using the SSH rm command, will it provide the same result?
Message 3 of 4
StephenB
Guru

Re: What does cp --reflink command actually do?

fb2k6 wrote:
Also, if I delete the source files/folder via explorer instead of using the SSH rm command, will it provide the same result?
Yes.
Message 4 of 4
Top Contributors
Discussion stats
  • 3 replies
  • 7667 views
  • 0 kudos
  • 2 in conversation
Announcements