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

Re: Enable Bitrot on Files: MV or CP?

rhpot1991
Guide

Enable Bitrot on Files: MV or CP?

So I want to make sure that bitrot protection is enabled on my files, I don't recall if I had it enabled on my shares before files were placed there.  According to the documentation you can create a new copy of the file and this will create CoW data for the new file.  Does moving a file with the mv command do the same thing, or do you need to use the cp command to create another copy?

 

I made a new share, mv'd the files between, then removed the old share.  Do I need to do this again with cp instead or did mv handle my task?

Model: RN626X|ReadyNAS 626X – 6 Bays with Intel® Xeon® Quad-Core Server Processor
Message 1 of 9

Accepted Solutions
rn_enthusiast
Virtuoso

Re: Enable Bitrot on Files: MV or CP?

You can use "lsattr" to check if a file has CoW enabled or not.

 

Here my txt file does not have CoW enabled, denoted by the "C" in the end.

root@Databak:~# lsattr /data/Data-dump/MyFile_NoCoW.txt
---------------C /data/Data-dump/MyFile_NoCoW.txt

Here is what a file looks like, that has CoW enabled.

root@Databak:~# lsattr /data/Data-dump/MyFile_CoW.txt
---------------- /data/Data-dump/MyFile_CoW.txt

I don't think the "mv" command is enough to trigger CoW on a file that has previously been marked for No CoW - due to reasons that @StephenB mentioned. I think you need to re-create the file - i.e. "cp"

 

But you can check on the files you moved 🙂

View solution in original post

Message 7 of 9

All Replies
StephenB
Guru

Re: Enable Bitrot on Files: MV or CP?


@rhpot1991 wrote:

 

I made a new share, mv'd the files between, then removed the old share.  Do I need to do this again with cp instead or did mv handle my task?


I'm not 100% sure, but I think you'll need to do it again with cp.

 

If you are moving from window file explorer, the move is turned into a copy/delete when you access the shares using normal credentials.  But if you access the full data volume using admin credentials, that doesn't happen - only the metadata is rewritten.

 

When you mv using ssh on the NAS, it's like that second case.  The mv completes much faster than cp will, but that is because the file data isn't being copied.  The bitrot protection feature depends on BTRFS checksums (plus RAID parity), and if they were turned off when you uploaded the files to the NAS, a "true" mv won't create them.

Message 2 of 9
rhpot1991
Guide

Re: Enable Bitrot on Files: MV or CP?

Everything from SSH, could do it via a network share but that would add network overhead.

 

MV across shares, takes some time - not instant.

MV within shares is instant. (note this was done after above, which may have created metadata?)

CP within a share is taking forever.

 

Hopefully someone from Netgear can chime in if an initial MV will create the metadata or not.

Message 3 of 9
StephenB
Guru

Re: Enable Bitrot on Files: MV or CP?


@rhpot1991 wrote:

Everything from SSH, could do it via a network share but that would add network overhead.

 

MV across shares, takes some time - not instant.

MV within shares is instant. (note this was done after above, which may have created metadata?)

CP within a share is taking forever.

 

Hopefully someone from Netgear can chime in if an initial MV will create the metadata or not.


Please don't double-post.  I replied here: https://community.netgear.com/t5/Using-your-ReadyNAS-in-Business/Enable-Bitrot-on-Files-MV-or-CP/m-p...

 

 

Message 4 of 9
rhpot1991
Guide

Re: Enable Bitrot on Files: MV or CP?

I replied to you.

Message 5 of 9
StephenB
Guru

Re: Enable Bitrot on Files: MV or CP?


@rhpot1991 wrote:

I replied to you.


Sorry, it was showing up as a separate thread when I replied.

 

Perhaps @rn_enthusiast or @mdgm will chime in.

 

In order for bit-rot protection to work, you need both BTRFS checksums and RAID parity.  My understanding is that the only safe way to create the BTRFS checksums is to copy the file data itself after checksums are enabled.  That won't happen if the files are moved.

 

There is a linux command that can also recalculate the checksums - but it is considered dangerous.  Normally the file system is unmounted before that command is run.

Message 6 of 9
rn_enthusiast
Virtuoso

Re: Enable Bitrot on Files: MV or CP?

You can use "lsattr" to check if a file has CoW enabled or not.

 

Here my txt file does not have CoW enabled, denoted by the "C" in the end.

root@Databak:~# lsattr /data/Data-dump/MyFile_NoCoW.txt
---------------C /data/Data-dump/MyFile_NoCoW.txt

Here is what a file looks like, that has CoW enabled.

root@Databak:~# lsattr /data/Data-dump/MyFile_CoW.txt
---------------- /data/Data-dump/MyFile_CoW.txt

I don't think the "mv" command is enough to trigger CoW on a file that has previously been marked for No CoW - due to reasons that @StephenB mentioned. I think you need to re-create the file - i.e. "cp"

 

But you can check on the files you moved 🙂

Message 7 of 9
rn_enthusiast
Virtuoso

Re: Enable Bitrot on Files: MV or CP?

Had a quick Google and interestingly enough, you might be able to change it on the fly, using "chattr". Have look here:
https://en.wikipedia.org/wiki/Chattr 

 

I haven't played around with this much though, changing CoW attributes, but I guess it should work 🙂

 

Message 8 of 9
rhpot1991
Guide

Re: Enable Bitrot on Files: MV or CP?

Confirmed that moved files have the C attribute, thus lacking CoW.  Newly copied files are created without the C attribute, thus having CoW.  Weird that they display it like this.

 

For the sake of making sure that CoW is enabled on these I think I should just copy and be done with it, rather than risking issues later if changing the attribute doesn't perform as needed.

Message 9 of 9
Top Contributors
Discussion stats
  • 8 replies
  • 1974 views
  • 3 kudos
  • 3 in conversation
Announcements