Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp cp --reflink=auto feature #33

Open
manujchandra opened this issue Dec 2, 2021 · 3 comments
Open

cp cp --reflink=auto feature #33

manujchandra opened this issue Dec 2, 2021 · 3 comments

Comments

@manujchandra
Copy link

manujchandra commented Dec 2, 2021

I am using Fedora 35 XFCE edition. One thing I have noticed:

I copied a 27 GB folder in Thunar in the same drive, the GUI file manager of XFCE. It took 4 seconds to copy.

If I run sudo btrfs fi du ~

It shows 27 GB is shared. In other words, only metadata was copied, not the actual data.

But if I use pycp on the same folder, it takes a few minutes to copy to the same drive. It means pycp is duplicating the files. I can see the free space also decreases.

I found here

that we can use cp --reflink=auto to copy with deduplication.

Is it possible to integrate this behavior of Thunar in pycp where it copies with de-duplication?

Thanks! 🙏🏽

@dmerejkowsky
Copy link
Collaborator

Is it possible to integrate this behavior [...] in pycp where it copies with de-duplication?

I don't think so. It seems cp --reflink uses some very specific, linux-only C code to achieve that, and pycp is very high-level and cross-platform.

That being said, feel free to try and write a patch

@manujchandra
Copy link
Author

I am leaving these links here just for future reference:

https://stackoverflow.com/questions/65492317/copy-file-in-python-with-copy-on-write-cow

https://bugs.python.org/issue37157

I will investigate them later.

@manujchandra
Copy link
Author

Leaving this here for future reference:

https://pypi.org/project/reflink/

from reflink import reflink

# Reflink copy 'large_file.img' to 'copy_of_file.img'
reflink("large_file.img", "copy_of_file.img")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants