Sparse files: Porovnání verzí

Z ZděchovNET
Skočit na navigaci Skočit na vyhledávání
 
Řádek 26: Řádek 26:


Without compression all data are transferred over network even the file is sparse.
Without compression all data are transferred over network even the file is sparse.
<source lang="bash">rsync -aS file user@host:/dir</source>
<source lang="bash">rsync -aS --progress file user@host:/dir</source>


With compression speed depends more on CPU performance as all data needs to be compressed. Sparse space is well compressed and transferred data greatly reduced. The data which can't be well compressed are transferred slower than without compression.
With compression speed depends more on CPU performance as all data needs to be compressed. Sparse space is well compressed and transferred data greatly reduced. The data which can't be well compressed are transferred slower than without compression.
<source lang="bash">rsync -aSz file user@host:/dir</source>
<source lang="bash">rsync -aSz --progress file user@host:/dir</source>


==Reclaim space on ext4 image==
==Reclaim space on ext4 image==

Aktuální verze z 24. 9. 2023, 11:50

Create sparse file

truncate -s 10G ./file

Copy locally

cp

cp from to

dd

dd if=srcFile of=dstFile iflag=direct oflag=direct bs=64K conv=sparse

Show real size

ls

Show real size and logical file size:

ls -lhs file

du

Show real file size:

du -sh file

Copy over network

rsync

Without compression all data are transferred over network even the file is sparse.

rsync -aS --progress file user@host:/dir

With compression speed depends more on CPU performance as all data needs to be compressed. Sparse space is well compressed and transferred data greatly reduced. The data which can't be well compressed are transferred slower than without compression.

rsync -aSz --progress file user@host:/dir

Reclaim space on ext4 image

Mount old image as loopback device:

mount old.raw /mnt/old

Get size of the file:

ls -l old.raw

Create second sparse image file with the same size:

truncate -s <size> new.raw

Format it with ext4 file system:

mkfs.ext4 new.raw

Mount new image as loopback device:

mount new.raw /mnt/new

Synchronize entire disk:

rsync -aSAXv /mnt/old/ /mnt/new

Unmount disks:

umount /mnt/old
umount /mnt/new

External links