MOVE and RENAME = COPY and DELETE ??

Status
Not open for further replies.

TrevInCarlton

Dabbler
Joined
Sep 18, 2018
Messages
39
I have come across various threads that cover this but without a definitive answer. I need to know, if I move a file or folder within the same dataset does zfs copy the folder and its contents to the new location and then deletes the old contents. I believe that this is what happens has I have looked at the partition under reporting and it grows during a MOVE although not yet looked to see the deletion (work in progress). I could not find an actual command for rename other than "mv", the same as move. It is possible that at some stage I may need to move or rename folders containing more the a tb of data so just need some clarification on this aspect of the ZFS file system.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
ZFS is copy on write (CoW), so what you say is correct, but also remember that snapshots (one of the key features of ZFS) also means data is not really removed from the disk until all snapshots that require it are expired/deleted.

mv within the same dataset should not result in a rewrite of the file content, but will result in the allocation tables being updated. mv outside of the source dataset will result in a duplication of data even if on the same disk(s)/pools.
 

TrevInCarlton

Dabbler
Joined
Sep 18, 2018
Messages
39
ZFS is copy on write (CoW), so what you say is correct, but also remember that snapshots (one of the key features of ZFS) also means data is not really removed from the disk until all snapshots that require it are expired/deleted.

mv within the same dataset should not result in a rewrite of the file content, but will result in the allocation tables being updated. mv outside of the source dataset will result in a duplication of data even if on the same disk(s)/pools.

Thanks for the input but I find it a bit contradictory
ZFS is copy on write (CoW), so what you say is correct
indicating using mv a copy is created before being deleted, whereas
mv within the same dataset should not result in a rewrite of the file content, but will result in the allocation tables being updated
would indicate that a copy is not created ? Are files treated different from folders ? Yes I understand moving or renaming to a different dataset will always result in a copy before the original being deleted. How can the same command result in a copy and not a copy ??
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
indicating using mv a copy is created before being deleted
No, that's not at all what CoW indicates. CoW means that the changed data is written to a new place, not simply overwritten. In the case of a mv within the same filesystem (that is, within the same dataset), the only changed data is metadata, so it's only the metadata that has a new copy written.
 
Status
Not open for further replies.
Top