I packed and compressed a folder to a .tar.gz archive.
After unpacking it was nearly twice as big.
du -sh /path/to/old/folder = 263M
du -sh /path/to/extracted/folder = 420M
I searched a lot and found out that tar is actually causing this issue by adding metadata or doing other weird stuff with it.
I made a diff on 2 files inside the folder, as well as a md5sum. There is absolutely no diff and the checksum is the exact same value. Yet, one file is as twice as big as the original one.
root@server:~# du -sh /path/to/old/folder/subfolder/file.mcapm /path/to/extracted/folder/subfolder/file.mcapm
1.1M /path/to/old/folder/subfolder/file.mcapm
2.4M /path/to/extracted/folder/subfolder/file.mcapm
root@server:~# diff /path/to/old/folder/subfolder/file.mcapm /path/to/extracted/folder/subfolder/file.mcapm
root@server:~#
root@server:~# md5sum /path/to/old/folder/subfolder/file.mcapm
root@server:~# f11787a7dd9dcaa510bb63eeaad3f2ad
root@server:~# md5sum /path/to/extracted/folder/subfolder/file.mcapm
root@server:~# f11787a7dd9dcaa510bb63eeaad3f2ad
I am not searching for different methods, but for a way to reduce the size of those files again to their original size.
How can I achieve that?
Best Answer
[this answer is assuming GNU tar and GNU cp]
That
.mcapm
file is probably sparse. Use the-S
(--sparse
)tar
option when creating the archive.Example:
You can also "re-sparse" a file afterwards with
cp --sparse=always
: