A sparse file is a file in which most of the contents of a file are empty characters.
The 100G disk file created by the virtual machine is, but the system does not immediately partition the space of 100G, but only to identify the virtual hard disk files are sparse files, until the data storage, then allocate space, which can greatly save disk utilization.
When a sparse file is Cp/scp/split/cat, it becomes a non-sparse file file by the identified sparse file, which results in a large amount of space.
This is not the result we want, you can copy/move/split the sparse file in the following way.
Create a test with a sparse file, size 1G:
DD If=/dev/zero of=test_sparse.log Bs=1 count=1 seek=1024m
To view files:
Ls-alsh Test_sparse.log
4.0K -rw-rw-r--1 lidq lidq 1.1G June 8 15:10 Test_sparse.log
Du-sh Test_sparse.log
4.0Ktest_sparse.log
You can see that the file size is not the same.
To compress a sparse file with tar:
TAR-ZCSVF test_sparse.log.tar.gz Test_sparse.log
To split a compressed file:
Split-b 1m-d-a 4 test_sparse.log.tar.gz test_sparse.log.tar.gz-
Merge split files:
Cat test_sparse.log.tar.gz-* > test_sparse.log.tar.gz
Sparse file (Baidu Encyclopedia): http://baike.baidu.com/item/%E7%A8%80%E7%96%8F%E6%96%87%E4%BB%B6
This article is from the "Old Farmer" blog, please make sure to keep this source http://jingwu.blog.51cto.com/921628/1933473
Compressing and splitting sparse files under Linux