파일의 “스파 스 니스”를 어떻게 출력합니까? 같습니다. $ fallocate -l 1000000 data $ measure_sparseness

실제로 데이터로 채워진 파일 공칭 크기를 어떻게 출력합니까? 마찬가지로 vmtouch쇼 얼마나 많은 파일은 현재 메모리에 …

워크 플로는 다음과 같습니다.

$ fallocate -l 1000000 data
$ measure_sparseness data
100%
$ fallocate -p -o 250000 -l 500000  data
$ measure_sparseness
50%

해결 방법 : 사용 du -bshdu -sh비교하십시오.



답변

find%S경우에도 “스파 스”라는 형식 지정자를

         %S     File's  sparseness.   This  is  calculated as (BLOCKSIZE*st_blocks / st_size).  The exact value you will get for an ordinary file of a certain
                 length is system-dependent.  However, normally sparse files will have values less than 1.0, and files which use indirect  blocks  may  have  a
                 value which is greater than 1.0.   The value used for BLOCKSIZE is system-dependent, but is usually 512 bytes.   If the file size is zero, the
                 value printed is undefined.  On systems which lack support for st_blocks, a file's sparseness is assumed to be 1.0.
$ fallocate -l 1000000 data
$ find data -printf '%S\n'
1.00352
$ fallocate -p -o 250000 -l 500000  data
$ find data -printf '%S\n'
0.507904


답변

당신이 경우 find해당 옵션, 70 년대이기 때문에 UNIX에 일이있는 방법이 없습니다 :

ls -ls file

사용 된 실제 블록 수와 기록 된 가장 높은 바이트를 인쇄합니다. 이를 통해 실제로 할당되지 않은 블록 수를 쉽게 계산할 수 있습니다.


답변

find‘s %S는 간단한 출력을 인쇄 하지만 자세한 내용은 sparsetest내가 작성한 오픈 소스와 여기 github을 참조하십시오 . 모든 구멍을 인쇄하려면 (예를 들어) 자유롭게 수정하십시오.

스파 스 할당에 문제가 보여주는 블로그 기사 여기를 사용하여 sparsetest문제를 디버깅 할 수 있습니다.


답변