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

Creating sprase image before compressing #187

Closed
dilyanpalauzov opened this issue Feb 8, 2021 · 2 comments
Closed

Creating sprase image before compressing #187

dilyanpalauzov opened this issue Feb 8, 2021 · 2 comments

Comments

@dilyanpalauzov
Copy link

In order to get smaller compressed image, place allocated by deleted files shall be zeroed. This is called “sparse image”. According to https://ext4.wiki.kernel.org/index.php/Ext4_VM_Images#Good_Tools_for_Making_Sparse_Images:_fstrim.2Fe2fsck.2Fzerofree to create a sparse image one has to call e2fsck -E discard $loopback.

• Call e2fsck -E discard $loopback on the resulting image.

@jfikar
Copy link

jfikar commented Feb 27, 2021

The command e2fsck -E discard $device does not seem to discard the free space. Even e2fsck -f -y -D -E discard $device does not work.

On contrary, the zerofree of dd if=/dev/zero of=zerofile;sync;sync;rm zerofile works just fine. One can also zero the first FAT partition, to decrease the image size. Then dd has to be used.

One can probably also use fstrim on the mounted image, but I'm not sure if it does not depend on the trimability of the system storage.

There is also a possibility to create a sparse file at the end, if you are not compressing it by fallocate -d image

@Drewsif
Copy link
Owner

Drewsif commented Feb 14, 2023

Duplicate of #59

@Drewsif Drewsif marked this as a duplicate of #59 Feb 14, 2023
@Drewsif Drewsif closed this as completed Feb 14, 2023
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

3 participants