trx
Published on 2025-06-04 / 20 Visits
0

稀疏文件查询

稀疏文件过多可能会影响数据迁移

find /root -type f -exec perl -e '
  for (@ARGV) {
    @s = stat;
    next unless -f _;
    $bs = $s[12] || 512;
    $blocks = $s[12];
    $size = $s[7];
    if ($blocks * 512 < $size) {
      printf "%s: size=%d, blocks=%d (sparse ratio=%.2f)\n", 
        $_, $size, $blocks, $size/($blocks*512);
    }
  }
' {} +