Sparse files: Porovnání verzí

Z ZděchovNET
Skočit na navigaci Skočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 1: Řádek 1:
==Create sparse file==
==Create sparse file==


truncate -s 10G ./file
<source lang="bash">truncate -s 10G ./file</source>


==Copy locally==
==Copy locally==


cp from to
<source lang="bash">cp from to</source>


==Show real size==
==Show real size==
Řádek 11: Řádek 11:
===ls===
===ls===
Show real size and logical file size:
Show real size and logical file size:
ls -lhs file
<source lang="bash">ls -lhs file</source>


===du===
===du===
Show real file size:
Show real file size:
du -sh file
<source lang="bash">du -sh file</source>


==Copy over network==
==Copy over network==
Řádek 21: Řádek 21:
===rsync===
===rsync===


rsync -aS file user@host:/dir
<source lang="bash">rsync -aS file user@host:/dir</source>

==Reclaim space on ext4 image==

Mount old image as loopback device:
<source lang="bash">mount old.raw /mnt/old</source>

Get size of the file:
<source lang="bash">ls -l old.raw</source>

Create second sparse image file with the same size:
<source lang="bash">truncate -s <size> new.raw</source>

Format it with ext4 file system:
<source lang="bash">mkfs.ext4 new.raw</source>

Mount new image as loopback device:
<source lang="bash">mount new.raw /mnt/new</source>

Synchronize entire disk:
<source lang="bash">rsync -aSAXv /mnt/old/ /mnt/new</source>

Unmount disks:
<source lang="bash">umount /mnt/old
umount /mnt/new</source>


=External links=
=External links=

Verze z 11. 8. 2022, 23:28

Create sparse file

truncate -s 10G ./file

Copy locally

cp from to

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

rsync -aS 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